pod扩容
[root@k8s-master01 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-85756b779-fpqrm 1/1 Running 0 49s 10.244.1.2 k8s-node01 <none> <none>
[root@k8s-master01 ~]#
[root@k8s-master01 ~]#
[root@k8s-master01 ~]#
[root@k8s-master01 ~]# kubectl scale --replicas=3 deployment/nginx-deployment
deployment.extensions/nginx-deployment scaled
[root@k8s-master01 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-85756b779-fpqrm 1/1 Running 0 89s 10.244.1.2 k8s-node01 <none> <none>
nginx-deployment-85756b779-m749m 1/1 Running 0 3s 10.244.2.3 k8s-node02 <none> <none>
nginx-deployment-85756b779-pwv8s 1/1 Running 0 3s 10.244.1.3 k8s-node01 <none> <none>
删除pod
[root@k8s-master01 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-deployment-85756b779-rwk2p 1/1 Running 0 2m7s 10.244.2.2 k8s-node02 <none> <none>
[root@k8s-master01 ~]#
[root@k8s-master01 ~]#
[root@k8s-master01 ~]#
[root@k8s-master01 ~]# kubectl delete pod nginx-deployment-85756b779-rwk2p
pod "nginx-deployment-85756b779-rwk2p" deleted
Harbor重启
修改配置之后重启
docker-compose down
cd /opt/harbor
./prepare
docker-compose up -d
修改SVC类型使外部可以访问内部服务
[root@k8s-master01 ~]# kubectl edit svc nginx-deployment
# Please edit the object below. Lines beginning with a '#' will be ignored,
# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
kind: Service
metadata:
creationTimestamp: "2020-07-21T09:49:27Z"
labels:
run: nginx-deployment
name: nginx-deployment
namespace: default
resourceVersion: "96865"
selfLink: /api/v1/namespaces/default/services/nginx-deployment
uid: 162d55d4-8554-4cf5-84e8-0dc5e08c245a
spec:
clusterIP: 10.109.46.42
externalTrafficPolicy: Cluster
ports:
- nodePort: 32650
port: 3000
protocol: TCP
targetPort: 80
selector:
run: nginx-deployment
sessionAffinity: None
type: NodePort # 将这里的 ClusterIP 改为 NodePort
status:
loadBalancer: {}
退出之后所有节点的对应端口都是开放可以访问的
[root@k8s-master01 ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22h
nginx-deployment NodePort 10.109.46.42 <none> 3000:32650/TCP 21h
查看容器日志
# kubectl log pod名称 (-c 如果里面有多个容器要指定容器名称,只有一个就不需要)
[root@k8s-master01 ~]# kubectl log myapp-pod -c test
log is DEPRECATED and will be removed in a future version. Use logs instead.
2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
2020/07/22 08:48:45 [emerg] 1#1: still could not bind()