DEV Community

Cover image for Mastering Kubernetes Proxy Command
Labby for LabEx

Posted on

1

Mastering Kubernetes Proxy Command

Introduction

This article covers the following tech skills:

Skills Graph

In this lab, you will learn how to use the Kubernetes proxy command to access the Kubernetes API server from your local machine. You will start with simple examples and gradually increase in complexity until you have a fully functional proxy.

The Kubernetes proxy command allows you to access the Kubernetes API server from your local machine without needing to expose the API server to the public internet. This can be useful for debugging and troubleshooting Kubernetes clusters.

Set Up a Basic Proxy

In this step, you will set up a basic proxy that can forward requests to the Kubernetes API server using the Kubernetes proxy command.

Here is the basic command you will use to set up the proxy:

kubectl proxy
Enter fullscreen mode Exit fullscreen mode

This command will start a proxy server on your local machine that listens on port 8001. You can test the proxy by making a request to http://localhost:8001/api/v1/pods (assuming you have pods running in your cluster).

Access the Kubernetes Api with Curl

Open a new terminal and use the following command to access the API server.

Here is the basic command you will use to access the API server with curl:

curl http://localhost:8001/api/v1/pods
Enter fullscreen mode Exit fullscreen mode

This command will retrieve a list of pods running in your cluster.

Summary

In this lab, you learned how to use the Kubernetes proxy command to access the Kubernetes API server from your local machine. You learned how to set up a basic proxy, access the API server with cURL and Python, authenticate with the API server, and use authenticated requests.

MindMap


🚀 Practice Now: Kubernetes Proxy Command


Want to Learn More?

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay