<p>I need to initialize my kubernetes cluster using a kubeadm config file due to some extra arguments that I need to pass, which are not directly available to <code>kubeadm init</code>.</p>

<p>I did create a config file and it works fine. I went throgh the <a href="https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2" rel="nofollow noreferrer">documentation</a> of the kubeadm config file but still not able to get which option is equivalent to the command line flag <code>--apiserver-advertise-address</code></p>

<p>My kubeadm version is <code>1.15.7</code></p>

<p>This is my current config:
Commented out lines are the options which I already tried but dosen't seem to work. </p>

<pre><code>#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: {}
</code></pre>

<p><a href="https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2#APIEndpoint" rel="nofollow noreferrer">This</a> is what I'm trying to configure. </p>

rohanmehto2
<p>To specify the <code>--apiserver-advertise-address</code> flag in the kubeadm config file use this in the init configuration:</p>

<pre><code>localAPIEndpoint:
  advertiseAddress: 192.168.224.22
  bindPort: 6443
</code></pre>

<p>Initially when I was using this the address changed but then the worker nodes were not able to join the cluster due to a CRI socket misconfiguration.</p>

<p>Turns out using <code>kubeadm config view</code> doesn't print out the entire configuration that was used during cluster creation. <code>The kind: InitConfiguration</code> is skipped, due to which the misconfiguration occured.</p>

<p>Use <code>kubeadm config print init-defaults</code> to get the init block of the config file. Then it should work.</p>

<p>Final working config file:</p>

<pre><code>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: {}
</code></pre>
