1-06 1 views
所有节点安装nfs-utils
1 |
yum -y install nfs-utils |
StatefulSet部署文档
这里以Nacos为例,需要注意我这里Nacos的启动模式是standalone,所以副本数只能为1
这种部署模式下,当pod被销毁不会影响nacos的数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
apiVersion: apps/v1 kind: StatefulSet metadata: name: nacos namespace: platform-dev spec: serviceName: nacos replicas: 1 selector: matchLabels: app: nacos template: metadata: labels: app: nacos annotations: pod.alpha.kubernetes.io/initialized: "true" spec: affinity: # 亲和性 podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: # Pod必须部署在满足条件的节点上 - labelSelector: matchExpressions: - key: "app" operator: In values: - nacos topologyKey: "kubernetes.io/hostname" containers: - image: nacos/nacos-server:1.4.1 name: nacos imagePullPolicy: Always # 镜像拉取策略 ports: # 容器开放端口 - containerPort: 8848 protocol: TCP - containerPort: 50258 protocol: UDP env: # nacos启动变量 - name: NACOS_SERVER_PORT value: "8848" - name: NACOS_APPLICATION_PORT value: "8848" - name: PREFER_HOST_MODE value: "hostname" - name: MODE value: "standalone" resources: {} securityContext: capabilities: {} privileged: true volumeMounts: # 容器中挂载点信息 - name: plugindir mountPath: /home/nacos/plugins/peer-finder - name: logdir mountPath: /home/nacos/logs - name: datadir mountPath: /home/nacos/data volumes: # NFS挂载信息 - name: datadir nfs: server: 192.168.111.116 path: /storage/k8s/platform-dev/nacos/data - name: plugindir nfs: server: 192.168.111.116 path: /storage/k8s/platform-dev/nacos/peer-finder - name: logdir nfs: server: 192.168.111.116 path: /storage/k8s/platform-dev/nacos/logs |
Service部署文档
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
apiVersion: v1 kind: Service metadata: name: nacos namespace: platform-dev labels: app: nacos spec: type: NodePort ports: - port: 8848 # service端口 protocol: TCP targetPort: 8848 # 容器端口 nodePort: 31848 # 指定在NodePort上的暴露接口 externalIPs: - 192.168.111.201 # 指定集群中某一个节点的IP,不指定表示集群中所有节点的IP均可使用,建议不指定 selector: app: nacos |
如果想赏钱,可以用微信扫描下面的二维码,一来能刺激我写博客的欲望,二来好维护云主机的费用; 另外再次标注博客原地址 itnotebooks.com 感谢!