kubeadm初始化配置文件范例

  1. 首先每个版本的kubeadm是不一样的,包含着一部分参数的弃用和新参数的启用,所以kubeadm init 初始化config文件,每个版本的配置内容也可能存在差异
  2. 官方提供的默认查询方法是:https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm-config/ kubeadm config print init-defaults
    kubeadm config print init-defaults --component-configs  [KubeProxyConfiguration KubeletConfiguration]
    kubeadm config print join-defaults
    kubeadm config print join-defaults --component-configs  [KubeProxyConfiguration KubeletConfiguration]
  3. 下面提供一个范例:
    k8s-init-master01.yaml

    apiVersion: kubeadm.k8s.io/v1beta2
    kind: InitConfiguration
    localAPIEndpoint:
      advertiseAddress: 192.168.10.241
      bindPort: 6443
    nodeRegistration:
      criSocket: /var/run/dockershim.sock
      name: master01
      taints:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
    ---
    apiVersion: kubeadm.k8s.io/v1beta2
    kind: ClusterConfiguration
    kubernetesVersion: v1.15.0
    imageRepository: gcr.azk8s.cn/google_containers
    apiServer:
      # extraArgs:
      #   authorization-mode: "Node,RBAC"
      certSANs:
      - "master01"
      - "master02"
      - "master03"
      - "192.168.10.241"
      - "192.168.10.242"
      - "192.168.10.243"
      - "192.168.10.240"
      - "127.0.0.1"
    controlPlaneEndpoint: "192.168.10.240:8443"
    dns:
      type: CoreDNS
    etcd:
      local:
        extraArgs:
          listen-client-urls: "https://127.0.0.1:2379,https://192.168.10.241:2379"
          advertise-client-urls: "https://192.168.10.241:2379"
          listen-peer-urls: "https://192.168.10.241:2380"
          initial-advertise-peer-urls: "https://192.168.10.241:2380"
          initial-cluster: "master01=https://192.168.10.241:2380"
        serverCertSANs:
          - master01
          - 192.168.10.241
        peerCertSANs:
          - master01
          - 192.168.10.241
      # external:
      #    endpoints:
      #    - https://192.168.10.241:2379
      #    - https://192.168.10.242:2379
      #    - https://192.168.10.243:2379
    networking:
      dnsDomain: cluster.local
      podSubnet: "10.244.0.0/16"
    ---
    apiVersion: kubeproxy.config.k8s.io/v1alpha1
    kind: KubeProxyConfiguration
    mode: "ipvs"

    #使用默认配置生成配置文件kubeadm config print init-defaults > k8s-init-master01.yaml
    #手动修改补全k8s-init-master01.yaml所需要的内容
    #提前拉取镜像kubeadm config images pull --config k8s-init-master01.yaml
    #初始化安装kubeadm init --config k8s-init-master01.yaml

You may also like...

发表评论