Setting up a Kubernetes master on a different IP

1.1k Views Asked by At

I'm trying to set up a Kubernetes master on an IP other than the one assigned to the default interface. These are the changes I made to my kubeadm-config.yml :

---
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
controlPlaneEndpoint: x.x.x.x
apiServer:
  extraArgs:
    advertise-address: x.x.x.x
  certSANs:
    - x.x.x.x
etcd:
  local:
    dataDir: /var/lib/etcd
    extraArgs:
      advertise-client-urls: https://x.x.x.x:2379
      initial-advertise-peer-urls: https://x.x.x.x:2380
      initial-cluster: my-hostname=https://x.x.x.x:2380
      listen-client-urls: https://127.0.0.1:2379,https://x.x.x.x:2379
      listen-peer-urls: https://x.x.x.x:2380
      initial-cluster-state: new
    serverCertSANs:
      - x.x.x.x
    peerCertSANs:
      - x.x.x.x

Where x.x.x.x is the non-default IP. Everything seems to be set correctly, except for the liveness probe of the api-server. At /etc/kubernetes/manifests/kube-apiserver.yaml I still see

livenessProbe:
  failureThreshold: 8
  httpGet:
    host: y.y.y.y
    path: /healthz
    port: 6443
    scheme: HTTPS

Where y.y.y.y is the old IP.

Does anyone know what key I need to add to my kubeadm-config.yml to set this right?

Sam

1

There are 1 best solutions below

1
On BEST ANSWER

Reproducing your configuration, I found out that the InitConfiguration part of kubeadm-config is required for that.

The following kubeadm-config.yaml part is supposed to instruct kubeadm to configure kube-apiserver according to your needs:

---
kind: InitConfiguration
apiVersion: kubeadm.k8s.io/v1beta2
localAPIEndpoint:
  advertiseAddress: "x.x.x.x"
  bindPort: 6443

# the next section is optional, but could be useful also
nodeRegistration:
  kubeletExtraArgs:
    cgroup-driver: "systemd"

For the full details please read related GoDoc page: