Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Configuring Kubectl to Access a Remote Cluster

Kubectl is a powerful tool for managing a Kubernetes cluster. While kubectl can be used from one of the servers that makes up your cluster, it can also be used from your local command line to manage the cluster remotely. In this learning activity, you will configure kubectl on one machine to interact with a Kubernetes cluster on another machine. After completing this activity, you will have hands-on experience in configuring kubectl to connect to a cluster remotely.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Aug 02, 2025
Duration
1h 0m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use.
Table of Contents
  1. Challenge

    Set the kubectl cluster data.

    You can set the cluster data like this. Be sure to set KUBERNETES_PUBLIC_ADDRESS to the public IP of your controller.

    KUBERNETES_PUBLIC_ADDRESS=<Controller public IP>
    
    kubectl config set-cluster kubernetes-the-hard-way 
      --certificate-authority=ca.pem 
      --embed-certs=true 
      --server=https://${KUBERNETES_PUBLIC_ADDRESS}:6443
    
  2. Challenge

    Set the credentials for kubectl.

    The credentials are the certificate and key files admin.pem and admin-key.pem. These can be found in the home directory on the workspace server. You can set them up for kubectl like this:

    kubectl config set-credentials admin 
      --client-certificate=admin.pem 
      --client-key=admin-key.pem
    
  3. Challenge

    Set the context for the cluster.

    Set the context like this:

    kubectl config set-context kubernetes-the-hard-way 
      --cluster=kubernetes-the-hard-way 
      --user=admin
    
  4. Challenge

    Use the new kubectl context to check which pods are currently running on the cluster.

    Configure kubectl to use the new context like this:

    kubectl config use-context kubernetes-the-hard-way
    

    Verify that everything is working with:

    kubectl get pods
    

    Since there are no pods right now, you should get the following response:

    No resources found.
    

    This indicates that kubectl is set up correctly to access the cluster!

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight