On-Prem k8s | Part 8

Generating kubectl config

In this section we will generate a kubeconfig file for the kubectl k8s utility based on the admin user credentials.

kubeconfig file

The kubeconfig file contains the information allowing to remotely connect to a Kubernetes cluster. It stores the following information:

    API server URL
    CA data
    Client cert data
    Cluster name
    User name

The context links the cluster information to the user information.

The config file is generated with kubectl and is usually stored in ~/.kube

As we have setup the API server in HA mode, we will use the load balancer’s IP ( as the API server IP.

kubectl config set-cluster kubernetes \
  --certificate-authority=ca.pem \
  --embed-certs=true \
kubectl config set-credentials admin \
  --client-certificate=admin.pem \
kubectl config set-context kubernetes \
  --cluster=kubernetes \
kubectl config use-context kubernetes


Check the health of the remote Kubernetes cluster:

kubectl get componentstatuses


NAME                 STATUS    MESSAGE              ERROR
controller-manager   Healthy   ok
scheduler            Healthy   ok
etcd-0               Healthy   {"health": "true"}
etcd-2               Healthy   {"health": "true"}
etcd-1               Healthy   {"health": "true"}

List the nodes in the remote Kubernetes cluster:

kubectl get nodes


NAME      STATUS       ROLES     AGE       VERSION
k8swrk1   NotReady     <none>    1h        v1.10.1
k8swrk2   NotReady     <none>    2h        v1.10.1
k8swrk3   NotReady     <none>    2h        v1.10.1


Now that we have our working kubeconfig file, we can copy it to the home folder in the .kube sub-directory.

If you already have some Kubernetes cluster configured, you will need to either “merge” your current config file with the new one or specify the config file used when invoking kubectl

More information on organizing access to Kubernetes clusters is available here

Next: Configuring Networking >

< Previous: Bootstrapping k8s Worker Nodes

  • Category
comments powered by Disqus