Kubernetes container cluster kubectl management Tools command (eight)

Source: Internet
Author: User

Create an App
[[email protected] ~]# kubectl run nginx--replicas=3 --labels="app=nginx-example" --image=nginx:1.10 --port=Replicas: 3 copies, default 1 Labels: identity recognition attribute, Image: Download from hub by default
View Apps

[Email protected] ~]# KubectlGetAll NAME ' ready STATUS ' restarts age pod/nginx-f95d765f9-bxgv90/1Containercreating02m pod/nginx-f95d765f9-pdq4x0/1Containercreating02m pod/nginx-f95d765f9-znxw20/1Containercreating02m NAME TYPE CLUSTER-ip external-IP PORT (S) Age service/kubernetes Clusterip10.10.10.1<none>443/TCP 21h NAME desired current up-to-DATE AVAILABLE Age deployment.extensions/nginx3 3 3 02m NAME desired current ready age Replicaset.extensions/nginx-f95d765f93 3 02m NAME desired current up-to-DATE AVAILABLE Age Deployment.apps/nginx3 3 3 02m NAME desired current ready age Replicaset.apps/nginx-f95d765f93 3 02m is in the middle of creation

View pod Details

[Email protected] ~]# Kubectl describe pod/nginx-f95d765f9-bxgv9

View Pod Labels

[Email protected] ~]# KubectlGetPods--show-Labelsname Ready STATUS restarts age Labelsnginx-f95d765f9-bxgv91/1Running09m app=nginx-example,pod-template-hash=951832195Nginx-f95d765f9-pdq4x1/1Running09m app=nginx-example,pod-template-hash=951832195Nginx-f95d765f9-znxw21/1Running09m app=nginx-example,pod-template-hash=951832195

See which node the pod is assigned to

[Email protected] ~]# KubectlGetPods-o widename Ready STATUS restarts age IP nodebusybox-5d4f595646-tqfp21/1Running22m172.17.45.4   192.168.1.102Nginx-f95d765f9-bxgv91/1Running014m172.17.47.2   192.168.1.103Nginx-f95d765f9-pdq4x1/1Running014m172.17.45.2   192.168.1.102Nginx-f95d765f9-znxw21/1Running014m172.17.47.3   192.168.1.103
 [[email protected] ~]# kubectl get  Deploy- o widename desired current up -to-date availabl E Age CONTAINERS IMAGES selectorbusybox  1  1  1  0   3m BusyBox busybox Run=busyboxnginx  3  3  3  3  15m nginx nginx:1.10  AP P=nginx-example 
Get Deployname      Desired   current up-to-DATE   AVAILABLE   agebusybox   1         1          1            1            5mnginx     3         3         3            3           17m
Publish your App

Release:

[[email protected] ~]# Kubectl get Deploy
NAME desired current up-to-date AVAILABLE age
BusyBox 1 1 1 1 5m
Nginx 3 3 3 3 17m


[Email protected] ~]# kubectl expose deployment Nginx--port=--type=nodeport Name=nginx-service

To view published apps via Svc

Get Svcname            TYPE        CLUSTER-ip   external-IP   PORT (S)        agekubernetes      clusterip   10.10 . 10.1   <none>        443/TCP        23hnginx-service   nodeport     10.10. 10.9   <none>        :36046/tcp   1m
Troubleshooting
// View Events Event kubectl describe pod name   // View events via deploy kubectl describe deploy/// View release details Kubectl describe Svc name  // View Log kubectl logs  pod name // Enter container to troubleshoot kubectl exec-it Pod Name bash
Update image Upgrade
// Update the current nginx:1.10 version to 1.11 Set image Deployments/nginx Nginx=nginx:1.11orkubectl Edit Deploy/nginx  Edit the image version number inside to save the exit
View publication status
// status of the deployment resources KUBECTL rollout status deploy/nginx//  release historical version Kubectl rollout history Deploy/nginx
Rolling back
// Fallback to previous fallback version Kubectl rollout undo deploy/Nginx default rollback   to previous version // View status kubectl  Rollout status deploy/nginx// back to the specified version kubectl rollout undo Deploy/nginx--to-revision=4 

Pod Copy expansion

// expanding the current pod to 5 kubectl scale Deploy/nginx--replicas=5 reduction is also the above command
Delete
// Delete podkubectl delete deployment.extensions/nginx// Delete Servicekubectl Delete service/nginx-Service// view getget Deploy

Kubernetes container cluster kubectl management Tools command (eight)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.