SuperAPI AI Directory

docker-kubectl-deploy

Deployment & operations

View repository

Updated 10-16 09:47

About this skill

Docker Kubectl Deploy

Use docker build → docker push → kubectl set image fixed workflow to publish the new image to the Kubernetes environment and wait for the rolling update to complete.

Quick Start

  • Confirm that the local machine is configured with:docker, and is already docker login the corresponding image registry;kubectl, and the target cluster is configured kubeconfig
  • Required information: image registry (without tag), K8s context/namespace/deployment/container, tag (optional)
  • Prefer to use the script:bash scripts/build_push_kubectl.sh --help

Workflow (recommended)

  1. Select image reference:<image-repo>:<tag>(tag is automatically generated by default)
  2. Build:docker build -t <image-repo>:<tag> ...
  3. Push:docker push <image-repo>:<tag>
  4. Deploy:kubectl set image deployment/<deployment> <container>=<image-repo>:<tag> -n <namespace>
  5. Verify:kubectl rollout status deployment/<deployment> -n <namespace>

Common commands (when not using the script)

docker build -t IMAGE_REPO:TAG -f Dockerfile .
docker push IMAGE_REPO:TAG

kubectl -n NAMESPACE set image deployment/DEPLOYMENT CONTAINER=IMAGE_REPO:TAG
kubectl -n NAMESPACE rollout status deployment/DEPLOYMENT --timeout=120s

Safety Checks

  • Before deployment, verify the target environment first:kubectl config current-context、kubectl -n <ns> get deploy <name>
  • Production environment changes: first confirm with the user kube-context/namespace/image/tag, then execute

Scripts

scripts/build_push_kubectl.sh

Build the image, push it to the registry, then use kubectl set image to update the Deployment and wait for the rollout to complete.