K8S CLI Pod Creation
2 minute read
Step 1: Ensure You Have kubectl Installed
Make sure you have kubectl
installed on your machine. You can download it from the Kubernetes website and follow the installation instructions for your operating system.
Step 2: Open a Terminal
Open your terminal or command prompt where you can run Kubernetes commands.
Step 3: Connect to Your Kubernetes Cluster
Make sure you are connected to your Kubernetes cluster. You can use the following command to check your connection:
kubectl cluster-info
If you are not connected, follow the instructions provided by your cluster provider to connect.
Step 4: Create a YAML File for the Pod
Create a new YAML file named support-pod-node.yaml
with the following content:
apiVersion: v1
kind: Pod
metadata:
name: support-pod-node
namespace: default
spec:
containers:
- name: support-pod-node
image: ubuntu:latest
command:
- "/bin/bash"
- "-c"
- |
apt-get update && \
apt-get install -y netcat-openbsd telnet dnsutils curl iputils-ping git && \
while true; do sleep 3600; done
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 200m
memory: 256Mi
nodeName: aks-nodename-13402868-vmss000003
Step 5: Apply the YAML File to Your Cluster
Run the following command to apply the YAML file to your Kubernetes cluster:
kubectl apply -f support-pod-node.yaml
This command will create the support-pod-node
pod in your cluster.
Step 6: Verify the Pod is Running
Check the status of the pod to ensure it is running:
kubectl get pods -n default
You should see the support-pod-node
listed as running.
Step 7: Access the Pod
To access the pod and run commands inside it, use the following command:
kubectl exec -it support-pod-node -- /bin/bash
This command will open an interactive shell inside the support-pod-node
pod.
Step 8: Troubleshoot and Support
You can now use the pod for troubleshooting and support tasks using the installed utilities like netcat
, telnet
, dnsutils
, curl
, ping
, and git
.
Feedback
Was this page helpful?
Glad to hear it!
Sorry to hear that.