开通容器服务

https://www.aliyun.com/product/kubernetes

开通前image.png

开通并创建集群后(这里使用按量付费的ECS机器,测试后即可释放)
image.png
配置节点完成后
image.png

配置无状态应用

一开始我是直接使用的 yaml 进行创建

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. labels:
  5. app: nginx
  6. name: nginx-deployment-basic
  7. namespace: default
  8. spec:
  9. progressDeadlineSeconds: 600
  10. replicas: 1
  11. revisionHistoryLimit: 10
  12. selector:
  13. matchLabels:
  14. app: nginx
  15. strategy:
  16. rollingUpdate:
  17. maxSurge: 25%
  18. maxUnavailable: 25%
  19. type: RollingUpdate
  20. template:
  21. metadata:
  22. labels:
  23. app: nginx
  24. spec:
  25. containers:
  26. - image: 'nginx:1.7.9'
  27. imagePullPolicy: IfNotPresent
  28. name: nginx
  29. ports:
  30. - containerPort: 80
  31. protocol: TCP
  32. readinessProbe:
  33. failureThreshold: 3
  34. httpGet:
  35. path: /
  36. port: 80
  37. scheme: HTTP
  38. initialDelaySeconds: 10
  39. periodSeconds: 10
  40. successThreshold: 1
  41. timeoutSeconds: 1
  42. resources: {}
  43. terminationMessagePath: /dev/termination-log
  44. terminationMessagePolicy: File
  45. dnsPolicy: ClusterFirst
  46. restartPolicy: Always
  47. schedulerName: default-scheduler
  48. securityContext: {}
  49. terminationGracePeriodSeconds: 30

结果是 failure , 因为我是VPC网络并且没有开通SLB和弹性IP,所以拉不下来镜像.

开通NAT网关

image.png

开通需要在NAT网关上添加SNAT条目,绑定ECS/交换机走NAT网关的流量进出

image.png

绑定时发现需要先申请弹性IP.

开通弹性IP&弹性IP绑定NAT网关

image.png