Kubernetes Quick Start: Step-by-Step Guide

This post records common Kubernetes operations and references for getting started quickly.

Aug 6, 2023 · 1 min read · 163 Words · -Views -Comments · Digital Life
🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

I recently needed to learn Kubernetes for work, so I recorded some common operations here.

Note: Images are from the web.

Terms

  • k8s

    Kubernetes, similar to how internationalization is abbreviated to i18n.

  • Ingress Manages HTTP/HTTPS routes from outside the cluster to internal services.

    https://static.1991421.cn/2023/2023-08-06-231900.jpeg

Common commands

# Install on Mac
brew install kubectl

# Upgrade CLI on Mac
brew upgrade kubectl

# Version
kubectl version


# Connect to Kubernetes cluster with kubectl
export KUBECONFIG=$KUBECONFIG:$HOME/Downloads/cls-xxxx-config
kubectl config --kubeconfig=$HOME/Downloads/cls-xxxx-config get-contexts
kubectl config --kubeconfig=$HOME/Downloads/cls-xxxx-config use-context cls-xxxx-xxxx-context-default

# View cluster
kubectl get pods -n kube-system

## Download files
kubectl exec -i [containerId] -- tar -cpf - -C '/apiserver-proxy' 'cert.pem' > download.tar

## Upload
 tar -cf '/Users/alanhe/Desktop/csr (1).tar' '/Users/alanhe/Desktop/csr (1).pem' | kubectl exec -i kubernetes-proxy-884c9c6c9-vkgtg -- tar -xf - -C '/apiserver-proxy/csr (1).tar'

Image push

Before deployment, the image must be pushed to the target registry.

docker build -t centos-lrzsz:latest .
docker tag centos-lrzsz:latest xxx.com/ai/xxx:xx

# Login to registry
docker login 
 
# Push
docker push xxx.com/ai/xxx:xx

References

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover