- Kubernetes 教程
- Kubernetes - 主页
- Kubernetes - 概述
- Kubernetes - 架构
- Kubernetes - 设置
- Kubernetes - 图像
- Kubernetes - 工作
- Kubernetes - 标签和选择器
- Kubernetes - 命名空间
- Kubernetes-节点
- Kubernetes-服务
- Kubernetes-Pod
- Kubernetes - 复制控制器
- Kubernetes - 副本集
- Kubernetes - 部署
- Kubernetes - 卷
- Kubernetes - 秘密
- Kubernetes - 网络策略
- 高级 Kubernetes
- Kubernetes-API
- Kubernetes-Kubectl
- Kubernetes - Kubectl 命令
- Kubernetes - 创建应用程序
- Kubernetes - 应用程序部署
- Kubernetes - 自动缩放
- Kubernetes - 仪表板设置
- Kubernetes - 监控
- Kubernetes 有用资源
- Kubernetes - 快速指南
- Kubernetes - 有用的资源
- Kubernetes - 讨论
Kubernetes - 应用程序部署
部署是将镜像转换为容器,然后将这些镜像分配给 Kubernetes 集群中的 Pod 的方法。这也有助于设置应用程序集群,其中包括服务、Pod、复制控制器和副本集的部署。集群的设置方式可以使部署在 Pod 上的应用程序可以相互通信。
在此设置中,我们可以在一个应用程序之上设置一个负载均衡器,将流量转移到一组 Pod,然后它们与后端 Pod 进行通信。Pod 之间的通信通过 Kubernetes 中内置的服务对象进行。
Ngnix 负载均衡器 Yaml 文件
apiVersion: v1 kind: Service metadata: name: oppv-dev-nginx labels: k8s-app: omni-ppv-api spec: type: NodePort ports: - port: 8080 nodePort: 31999 name: omninginx selector: k8s-app: appname component: nginx env: dev
Ngnix 复制控制器 Yaml
apiVersion: v1 kind: ReplicationController metadata: name: appname spec: replicas: replica_count template: metadata: name: appname labels: k8s-app: appname component: nginx env: env_name spec: nodeSelector: resource-group: oppv containers: - name: appname image: IMAGE_TEMPLATE imagePullPolicy: Always ports: - containerPort: 8080 resources: requests: memory: "request_mem" cpu: "request_cpu" limits: memory: "limit_mem" cpu: "limit_cpu" env: - name: BACKEND_HOST value: oppv-env_name-node:3000
前端服务Yaml文件
apiVersion: v1 kind: Service metadata: name: appname labels: k8s-app: appname spec: type: NodePort ports: - name: http port: 3000 protocol: TCP targetPort: 3000 selector: k8s-app: appname component: nodejs env: dev
前端复制控制器 Yaml 文件
apiVersion: v1 kind: ReplicationController metadata: name: Frontend spec: replicas: 3 template: metadata: name: frontend labels: k8s-app: Frontend component: nodejs env: Dev spec: nodeSelector: resource-group: oppv containers: - name: appname image: IMAGE_TEMPLATE imagePullPolicy: Always ports: - containerPort: 3000 resources: requests: memory: "request_mem" cpu: "limit_cpu" limits: memory: "limit_mem" cpu: "limit_cpu" env: - name: ENV valueFrom: configMapKeyRef: name: appname key: config-env
后端服务yaml文件
apiVersion: v1 kind: Service metadata: name: backend labels: k8s-app: backend spec: type: NodePort ports: - name: http port: 9010 protocol: TCP targetPort: 9000 selector: k8s-app: appname component: play env: dev
支持的复制控制器 Yaml 文件
apiVersion: v1 kind: ReplicationController metadata: name: backend spec: replicas: 3 template: metadata: name: backend labels: k8s-app: beckend component: play env: dev spec: nodeSelector: resource-group: oppv containers: - name: appname image: IMAGE_TEMPLATE imagePullPolicy: Always ports: - containerPort: 9000 command: [ "./docker-entrypoint.sh" ] resources: requests: memory: "request_mem" cpu: "request_cpu" limits: memory: "limit_mem" cpu: "limit_cpu" volumeMounts: - name: config-volume mountPath: /app/vipin/play/conf volumes: - name: config-volume configMap: name: appname