我是靠谱客的博主 受伤电话,最近开发中收集的这篇文章主要介绍kubernetes deployment etcd 单节点,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1、node节点打label

kubectl label nodes cn-qingdao.192.168.9.111 etcd=etcd

2、以下为 etcd_deployment yaml文件

cat api_deploy.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:
  name: etcd
  namespace: license
spec:
  replicas: 1   #指定Pod副本数
  selector:             #指定Pod的选择器
    matchLabels:
      app: etcd
  template:
    metadata:
      labels:   #给Pod打label
        app: etcd
    spec:
      volumes: 
      - name: localtime
        hostPath: 
          path: /usr/share/zoneinfo/Asia/Shanghai
      nodeSelector:   # 使用节点选择器将Pod调度到指定label的节点
        etcd: etcd 
      containers:
      - name: etcd
        image: registry.cn-hangzhou.aliyuncs.com/coreos_etcd/etcd:v3
        imagePullPolicy: Always
        command:
        - /usr/local/bin/etcd
        args:
        - -name
        - etcd0
        - -data-dir
        - /etcd-data
        - -advertise-client-urls
        - http://192.168.9.111:2379,http://192.168.9.111:4001
        - -listen-client-urls
        - http://0.0.0.0:2379,http://0.0.0.0:4001
        - -initial-advertise-peer-urls
        - http://192.168.9.111:2380
        - -listen-peer-urls
        - http://0.0.0.0:2380
        - -initial-cluster-token
        - docker-etcd
        - -initial-cluster
        - etcd0=http://192.168.9.111:2380
        - -initial-cluster-state
        - new
        ports:
        - name: client
          containerPort: 2379
        - name: peer
          containerPort: 2380
        resources:
          requests:
            memory: 1000Mi
            cpu: 400m
          limits:
            memory: 2000Mi
            cpu: 600m
        volumeMounts:
        - name: localtime
          mountPath: /etc/localtime

3、以下为 etcd_svc 文件

cat api_svc.yaml 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: etcd
  name: etcd
  namespace: license
spec:
  ports:
  - name: client
    port: 2379
    protocol: TCP
    targetPort: 2379
  - name: peer
    port: 2380
    protocol: TCP
    targetPort: 2380
  selector:
    app: etcd

4、创建etcd_deployment及etcd_svc

kubectl apply -f etcd_deployment.yaml
kubectl apply -f etcd_svc.yaml

5、查看是否成功

[root@localhost ]# kubectl get pod,svc -n etcd | grep etcd
pod/etcd-5dd47887bd-mgvvz             1/1     Running   0          101m
service/etcd             ClusterIP   172.21.0.73     <none>        2379/TCP,2380/TCP   100m

最后

以上就是受伤电话为你收集整理的kubernetes deployment etcd 单节点的全部内容,希望文章能够帮你解决kubernetes deployment etcd 单节点所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部