kubeadm init --apiserver-advertise-address 配置文件中的等效标志
kubeadm init --apiserver-advertise-address flag equivalent in config file
我需要使用 kubeadm 配置文件初始化我的 kubernetes 集群,因为我需要传递一些额外的参数,这些参数不能直接用于 kubeadm init
。
我确实创建了一个配置文件,它工作正常。我浏览了 kubeadm 配置文件的 documentation,但仍然无法获得哪个选项相当于命令行标志 --apiserver-advertise-address
我的 kubeadm 版本是 1.15.7
这是我当前的配置:
注释掉的行是我已经尝试过但似乎不起作用的选项。
#apiVersion: kubeadm.k8s.io/v1beta2
#kind: InitConfiguration
#APIEndpoint:
# advertiseAddress: "192.168.224.22"
# bindPort: 6443
#controlPlaneEndpoint: "192.168.224.22:6443"
apiServer:
advertiseAddress: "192.168.224.22"
extraArgs:
authorization-mode: Node,RBAC
# advertise-address: 192.168.224.22
authentication-token-webhook-config-file: /webhook/webhook-config.yaml
extraVolumes:
- name: "webhook-conf"
hostPath: "/webhook/"
mountPath: "/webhook/"
readOnly: true
pathType: DirectoryOrCreate
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
#APIEndpoint:
# advertiseAddress: "192.168.224.22"
# bindPort: 6443
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.10
networking:
# advertiseAddress: "192.168.224.22"
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
This 是我要配置的内容。
要在 kubeadm 配置文件中指定 --apiserver-advertise-address
标志,请在初始化配置中使用:
localAPIEndpoint:
advertiseAddress: 192.168.224.22
bindPort: 6443
最初,当我使用这个地址时,地址发生了变化,但后来由于 CRI 套接字配置错误,工作节点无法加入集群。
原来使用 kubeadm config view
并没有打印出集群创建期间使用的整个配置。 The kind: InitConfiguration
被跳过,因此发生配置错误。
使用kubeadm config print init-defaults
获取配置文件的初始化块。然后它应该工作。
最终工作配置文件:
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.224.22
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: hostname1
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
extraArgs:
authorization-mode: Node,RBAC
authentication-token-webhook-config-file: /webhook/webhook-config.yaml
extraVolumes:
- name: "webhook-conf"
hostPath: "/webhook/"
mountPath: "/webhook/"
readOnly: true
pathType: DirectoryOrCreate
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.10
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
我需要使用 kubeadm 配置文件初始化我的 kubernetes 集群,因为我需要传递一些额外的参数,这些参数不能直接用于 kubeadm init
。
我确实创建了一个配置文件,它工作正常。我浏览了 kubeadm 配置文件的 documentation,但仍然无法获得哪个选项相当于命令行标志 --apiserver-advertise-address
我的 kubeadm 版本是 1.15.7
这是我当前的配置: 注释掉的行是我已经尝试过但似乎不起作用的选项。
#apiVersion: kubeadm.k8s.io/v1beta2
#kind: InitConfiguration
#APIEndpoint:
# advertiseAddress: "192.168.224.22"
# bindPort: 6443
#controlPlaneEndpoint: "192.168.224.22:6443"
apiServer:
advertiseAddress: "192.168.224.22"
extraArgs:
authorization-mode: Node,RBAC
# advertise-address: 192.168.224.22
authentication-token-webhook-config-file: /webhook/webhook-config.yaml
extraVolumes:
- name: "webhook-conf"
hostPath: "/webhook/"
mountPath: "/webhook/"
readOnly: true
pathType: DirectoryOrCreate
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
#APIEndpoint:
# advertiseAddress: "192.168.224.22"
# bindPort: 6443
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.10
networking:
# advertiseAddress: "192.168.224.22"
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}
This 是我要配置的内容。
要在 kubeadm 配置文件中指定 --apiserver-advertise-address
标志,请在初始化配置中使用:
localAPIEndpoint:
advertiseAddress: 192.168.224.22
bindPort: 6443
最初,当我使用这个地址时,地址发生了变化,但后来由于 CRI 套接字配置错误,工作节点无法加入集群。
原来使用 kubeadm config view
并没有打印出集群创建期间使用的整个配置。 The kind: InitConfiguration
被跳过,因此发生配置错误。
使用kubeadm config print init-defaults
获取配置文件的初始化块。然后它应该工作。
最终工作配置文件:
apiVersion: kubeadm.k8s.io/v1beta2
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: abcdef.0123456789abcdef
ttl: 24h0m0s
usages:
- signing
- authentication
kind: InitConfiguration
localAPIEndpoint:
advertiseAddress: 192.168.224.22
bindPort: 6443
nodeRegistration:
criSocket: /var/run/dockershim.sock
name: hostname1
taints:
- effect: NoSchedule
key: node-role.kubernetes.io/master
---
apiServer:
extraArgs:
authorization-mode: Node,RBAC
authentication-token-webhook-config-file: /webhook/webhook-config.yaml
extraVolumes:
- name: "webhook-conf"
hostPath: "/webhook/"
mountPath: "/webhook/"
readOnly: true
pathType: DirectoryOrCreate
timeoutForControlPlane: 4m0s
apiVersion: kubeadm.k8s.io/v1beta2
certificatesDir: /etc/kubernetes/pki
clusterName: kubernetes
controllerManager: {}
dns:
type: CoreDNS
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
kind: ClusterConfiguration
kubernetesVersion: v1.15.10
networking:
dnsDomain: cluster.local
podSubnet: 10.244.0.0/16
serviceSubnet: 10.96.0.0/12
scheduler: {}