Connecting to a Cluster

Use the kubectl package to connect to a Kubernetes cluster.

After creating a Kubernetes cluster, a Kubernetes configuration file is created so you can access the cluster using the kubectl command. Install kubectl on the localhost (the host with ocne installed on which you created the cluster). If you install kubectl on a different system, copy the kubeconfig file to the system.

  1. Install the kubectl package on the localhost.
    sudo dnf install kubectl
  2. Set the kubeconfig file location using an environment variable.
    export KUBECONFIG=$HOME/.kube/kubeconfig.cluster_name

    Replace cluster_name with the name you used to create the cluster. The default is ocne.

  3. (Optional) Persist the environment variable.

    Add the environment variable to the .bashrc file:

    echo 'export KUBECONFIG=$HOME/.kube/kubeconfig.cluster_name' >> $HOME/.bashrc
  4. Verify that you can use kubectl to connect to the cluster.

    For example:

    kubectl get deployments --all-namespaces