pod扩容

  1. [root@k8s-master01 ~]# kubectl get pod -o wide
  2. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  3. nginx-deployment-85756b779-fpqrm 1/1 Running 0 49s 10.244.1.2 k8s-node01 <none> <none>
  4. [root@k8s-master01 ~]#
  5. [root@k8s-master01 ~]#
  6. [root@k8s-master01 ~]#
  7. [root@k8s-master01 ~]# kubectl scale --replicas=3 deployment/nginx-deployment
  8. deployment.extensions/nginx-deployment scaled
  9. [root@k8s-master01 ~]# kubectl get pod -o wide
  10. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  11. nginx-deployment-85756b779-fpqrm 1/1 Running 0 89s 10.244.1.2 k8s-node01 <none> <none>
  12. nginx-deployment-85756b779-m749m 1/1 Running 0 3s 10.244.2.3 k8s-node02 <none> <none>
  13. nginx-deployment-85756b779-pwv8s 1/1 Running 0 3s 10.244.1.3 k8s-node01 <none> <none>

删除pod

  1. [root@k8s-master01 ~]# kubectl get pod -o wide
  2. NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
  3. nginx-deployment-85756b779-rwk2p 1/1 Running 0 2m7s 10.244.2.2 k8s-node02 <none> <none>
  4. [root@k8s-master01 ~]#
  5. [root@k8s-master01 ~]#
  6. [root@k8s-master01 ~]#
  7. [root@k8s-master01 ~]# kubectl delete pod nginx-deployment-85756b779-rwk2p
  8. pod "nginx-deployment-85756b779-rwk2p" deleted

Harbor重启

修改配置之后重启

  1. docker-compose down
  2. cd /opt/harbor
  3. ./prepare
  4. docker-compose up -d

修改SVC类型使外部可以访问内部服务

  1. [root@k8s-master01 ~]# kubectl edit svc nginx-deployment
  2. # Please edit the object below. Lines beginning with a '#' will be ignored,
  3. # and an empty file will abort the edit. If an error occurs while saving this file will be
  4. # reopened with the relevant failures.
  5. #
  6. apiVersion: v1
  7. kind: Service
  8. metadata:
  9. creationTimestamp: "2020-07-21T09:49:27Z"
  10. labels:
  11. run: nginx-deployment
  12. name: nginx-deployment
  13. namespace: default
  14. resourceVersion: "96865"
  15. selfLink: /api/v1/namespaces/default/services/nginx-deployment
  16. uid: 162d55d4-8554-4cf5-84e8-0dc5e08c245a
  17. spec:
  18. clusterIP: 10.109.46.42
  19. externalTrafficPolicy: Cluster
  20. ports:
  21. - nodePort: 32650
  22. port: 3000
  23. protocol: TCP
  24. targetPort: 80
  25. selector:
  26. run: nginx-deployment
  27. sessionAffinity: None
  28. type: NodePort # 将这里的 ClusterIP 改为 NodePort
  29. status:
  30. loadBalancer: {}
  31. 退出之后所有节点的对应端口都是开放可以访问的
  32. [root@k8s-master01 ~]# kubectl get svc
  33. NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
  34. kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22h
  35. nginx-deployment NodePort 10.109.46.42 <none> 3000:32650/TCP 21h

查看容器日志

  1. # kubectl log pod名称 (-c 如果里面有多个容器要指定容器名称,只有一个就不需要)
  2. [root@k8s-master01 ~]# kubectl log myapp-pod -c test
  3. log is DEPRECATED and will be removed in a future version. Use logs instead.
  4. 2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
  5. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
  6. 2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
  7. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
  8. 2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
  9. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
  10. 2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
  11. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
  12. 2020/07/22 08:48:45 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)
  13. nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address in use)
  14. 2020/07/22 08:48:45 [emerg] 1#1: still could not bind()