apiVersion: kubeadm.k8s.io/v1beta3
kind: InitConfiguration
# 配置运行时设置, 包括 启动引导令牌以及所有与 kubeadm 所在节点相关的设置
# 仅用于第一次运行 kubeadm init 命令


# 此处是附加到 group
bootstrapTokens:
- token: abcdef.0123456789abcdex
  description: "kubeadm bootstrap token"
  groups:
    - system:bootstrappers:kubeadm:default-node-token
  ttl: 48h0m0s
  usages:
  - signing
  - authentication


# 代表的是要部署到此节点上的 API 服务器示例的端点
localAPIEndpoint:
  # 本节点 apiserver 的地址; 默认从自动路由获取 hostname -i
  advertiseAddress: 10.2.2.50
  bindPort: 6443

# 向集群注册新节点相关的字段
# 定制节点名称, 要使用的 CRI 套接字或者其他仅对当前节点起作用的设置 (例如节点 IP 地址)
nodeRegistration:
  # containerd
  criSocket: unix:///var/run/containerd/containerd.sock

  # 如果是 docker, 需要换成 cri-docker
  # criSocket: unix:///var/run/cri-dockerd.sock
  imagePullPolicy: IfNotPresent
  name: w50
  taints:       # 是否添加污点, 默认是 null

  # 允许 master 运行容器实例的污点
    - key: node-role.kubernetes.io/master
      effect: PreferNoSchedule

  # 当前节点注册时可以忽略的一些错误
  # ignorePreflightErrors:
      # - IsPrivilegedUser
      #   imagePullPolicy: "IfNotPresent"

---
apiVersion: kubeadm.k8s.io/v1beta3

# 定制集群范围的设置
kind: ClusterConfiguration

kubernetesVersion: 1.26.3

clusterName: kubernetes
controlPlaneEndpoint: 10.2.2.50:6443
# 声明集群 apiserver 的 vip 地址或 dns

certificatesDir: /etc/kubernetes/pki  # 默认证书目录

# 仓库, 默认 registry.k8s.io, 可以指定命名空间, 如 registry.wait/cwx/
imageRepository: registry.wait/cwx/k8s
# imageRepository: registry.wait

# 包含集群的网络拓扑配置
# 使用这一部分可以定制 Pod 的 子网或者 Service 的子网
networking:
  dnsDomain: cluster.local
  serviceSubnet: 10.10.0.0/16       # service subnet
  podSubnet: 10.20.0.0/16           # pod 子网范围


# 配置 ETCD
etcd:
  # 本地 etcd
  # local:
  #   imageRepository: "registry.k8s.io"
  #   imageTag: "3.2.24"
  #   dataDir: "/var/lib/etcd"
  #   extraArgs:
  #     listen-client-urls: "http://10.100.0.1:2379"
  #   serverCertSANs:
  #   -  "ec2-10-100-0-1.compute-1.amazonaws.com"
  #   peerCertSANs:
  #   - "10.100.0.1"

  # 外部 etcd, 和 local 互斥
  external:
    # endpoints:
    #   - "https://10.2.4.50:2379"
    #   - "https://10.2.4.51:2379"
    #   - "https://10.2.4.52:2379"
    # caFile: /opt/k8s/cert/cwxCA.pem
    # certFile: /opt/k8s/cert/etcd.pem
    # keyFile: /opt/k8s/cert/etcd-key.pem

    endpoints:
      - "http://10.2.1.5:2370"
      - "http://10.2.1.5:2371"
      - "http://10.2.1.5:2372"


apiServer:
  timeoutForControlPlane: 4m0s    # 等待 API 服务器开始运行的超时时间
  extraArgs:
    authorization-mode: "Node,RBAC"
  # extraVolumes:
  # - name: "some-volume"
  #   hostPath: "/etc/some-path"
  #   mountPath: "/etc/some-pod-path"
  #   readOnly: false
  #   pathType: File
  # certSANs:
  # - "10.100.1.1"
  # - "ec2-10-100-0-1.compute-1.amazonaws.com"
  # timeoutForControlPlane: 4m0s


controllerManager: {}
  # extraArgs:
  #   "node-cidr-mask-size": "20"
  # extraVolumes:
  # - name: "some-volume"
  #   hostPath: "/etc/some-path"
  #   mountPath: "/etc/some-pod-path"
  #   readOnly: false
  #   pathType: File

scheduler: {}
  # extraArgs:
  #   address: "10.100.0.1"
  # extraVolumes:
  # - name: "some-volume"
  #   hostPath: "/etc/some-path"
  #   mountPath: "/etc/some-pod-path"
  #   readOnly: false
  #   pathType: File

dns:
# dns 相关的配置, 看文档也只能更换镜像的功能, 默认也就是 CoreDNS
  imageRepository: registry.wait/cwx
  imageTag: v1.9.3

---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
authentication:
  anonymous:
    enabled: false
  webhook:
    cacheTTL: 0s
    enabled: true
  x509:
    clientCAFile: /etc/kubernetes/pki/ca.crt
authorization:
  mode: Webhook
  webhook:
    cacheAuthorizedTTL: 0s
    cacheUnauthorizedTTL: 0s
cgroupDriver: systemd           # 关键的配置
clusterDNS:
- 10.10.0.10                    # 推荐值就是 service subnet 的 x.x.x.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s
evictionPressureTransitionPeriod: 0s
fileCheckFrequency: 0s
healthzBindAddress: 127.0.0.1
healthzPort: 10248
httpCheckFrequency: 0s
imageMinimumGCAge: 0s


# image: registry.wait/kube-apiserver:v1.26.1


logging:
  flushFrequency: 0
  options:
    json:
      infoBufferSize: "0"
  verbosity: 0
memorySwap: {}
nodeStatusReportFrequency: 0s
nodeStatusUpdateFrequency: 0s
rotateCertificates: true
runtimeRequestTimeout: 0s
shutdownGracePeriod: 0s
shutdownGracePeriodCriticalPods: 0s
staticPodPath: /etc/kubernetes/manifests
streamingConnectionIdleTimeout: 0s
syncFrequency: 0s
volumeStatsAggPeriod: 0s

---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
# 更改传递给在集群中部署的 kube-proxy 实例 的配置

bindAddress: 0.0.0.0
bindAddressHardFail: false
clientConnection:
  acceptContentTypes: ""
  burst: 0
  contentType: ""
  kubeconfig: /var/lib/kube-proxy/kubeconfig.conf
  qps: 0
clusterCIDR: ""
configSyncPeriod: 0s
conntrack:
  maxPerCore: null
  min: null
  tcpCloseWaitTimeout: null
  tcpEstablishedTimeout: null
detectLocal:
  bridgeInterface: ""
  interfaceNamePrefix: ""
detectLocalMode: ""
enableProfiling: false
healthzBindAddress: ""
hostnameOverride: ""
iptables:
  localhostNodePorts: null
  masqueradeAll: false
  masqueradeBit: null
  minSyncPeriod: 0s
  syncPeriod: 0s
ipvs:
  excludeCIDRs: null
  minSyncPeriod: 0s
  scheduler: ""
  strictARP: false
  syncPeriod: 0s
  tcpFinTimeout: 0s
  tcpTimeout: 0s
  udpTimeout: 0s

metricsBindAddress: ""
mode: "ipvs"                  # 手动指定 ipvs 默认, 默认是 iptables
nodePortAddresses: null
oomScoreAdj: null
portRange: ""
showHiddenMetricsForVersion: ""
winkernel:
  enableDSR: false
  forwardHealthCheckVip: false
  networkName: ""
  rootHnsEndpointName: ""
  sourceVip: ""
