zoukankan      html  css  js  c++  java
  • 一键建立zookeeper集群

    使用yaml文件的好处,通过service name来进行pod间的服务发现,

    集群配置dns.

    [root@k8s-master ~]# cat zookeeper-cluster.yaml 
    apiVersion: extensions/v1beta1
    kind: Deployment 
    metadata: 
      name: zookeeper-1
    spec: 
      replicas: 1
      template: 
        metadata: 
          labels: 
            name: zookeeper-1 
        spec: 
          containers: 
            - name: zookeeper-1
              image: docker.io/zookeeper:3.4.11
              imagePullPolicy: IfNotPresent
              env:
              - name: ZOO_MY_ID
                value: "1"
              - name: ZOO_SERVERS
                value: "server.1=0.0.0.0:2888:3888 server.2=zookeeper-2:2888:3888 server.3=zookeeper-3:2888:3888"
              ports:
              - containerPort: 2181
    
    ---
    
    apiVersion: extensions/v1beta1 
    kind: Deployment
    metadata:
      name: zookeeper-2
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            name: zookeeper-2
        spec:
          containers:
            - name: zookeeper-2
              image: docker.io/zookeeper:3.4.11
              imagePullPolicy: IfNotPresent
              env:
              - name: ZOO_MY_ID
                value: "2"
              - name: ZOO_SERVERS
                value: "server.1=zookeeper-1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zookeeper-3:2888:3888"
              ports:
              - containerPort: 2181
    
    ---
    
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: zookeeper-3
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            name: zookeeper-3
        spec:
          containers:
            - name: zookeeper-3
              image: docker.io/zookeeper:3.4.11
              imagePullPolicy: IfNotPresent
              env:
              env:
              - name: ZOO_MY_ID
                value: "3"
              - name: ZOO_SERVERS
                value: "server.1=zookeeper-1:2888:3888 server.2=zookeeper-2:2888:3888 server.3=0.0.0.0:2888:3888"
              ports:
              - containerPort: 2181
    ---
    
    apiVersion: v1 
    kind: Service 
    metadata: 
      name: zookeeper-1 
      labels:
        name: zookeeper-1
    spec: 
      ports: 
        - name: client
          port: 2181
          protocol: TCP
        - name: followers
          port: 2888
          protocol: TCP
        - name: election
          port: 3888
          protocol: TCP
      selector: 
        name: zookeeper-1
    
    ---
    
    apiVersion: v1 
    kind: Service 
    metadata: 
      name: zookeeper-2
      labels:
        name: zookeeper-2
    spec: 
      ports: 
        - name: client
          port: 2181
          protocol: TCP
        - name: followers
          port: 2888
          protocol: TCP
        - name: election
          port: 3888
          protocol: TCP
      selector: 
        name: zookeeper-2
    
    ---
    
    apiVersion: v1 
    kind: Service 
    metadata: 
      name: zookeeper-3
      labels:
        name: zookeeper-3
    spec: 
      ports: 
        - name: client
          port: 2181
          protocol: TCP
        - name: followers
          port: 2888
          protocol: TCP
        - name: election
          port: 3888
          protocol: TCP
      selector: 
        name: zookeeper-3
  • 相关阅读:
    Nginx 413 Request Entity Too Large
    Docker 搭建一个多端同步网盘-Nextcloud
    FTP主动模式(PORT)与被动模式(PASV)
    Linux安装与使用FTP服务-vsftpd
    Mac FTP工具推荐-Transmit
    Nginx配置动静分离
    Nginx解决跨域问题(CORS)
    CentOS 7 之找回失落的ifconfig
    CentOS 7 之安装篇
    深入研究MiniMVC之后续篇
  • 原文地址:https://www.cnblogs.com/ericnie/p/7991168.html
Copyright © 2011-2022 走看看