Pod: k8s minimum deployment unit, a collection of containers
Deployment: the most common controller for higher-level deployment and management of pods
Service: provides load balancing for a group of pods and provides unified access to the outside world
Label: label, attached to a resource, used to associate objects, query and filter
Namespaces: namespace. The logical isolation of objects is also conducive to permission control
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose use replication controller, service, deployment perhaps pod And expose it as a new Kubernetes Service
run Run a specified mirror in the cluster
set by objects Sets a specified feature
Basic Commands (Intermediate):
explain View documents for resources
get Show one or more resources
edit Edit a resource on the server
delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
Deploy Commands:
rollout Manage the rollout of a resource
scale by Deployment, ReplicaSet, Replication Controller perhaps Job Set a new number of copies
autoscale Automatically adjust one Deployment, ReplicaSet, perhaps ReplicationController Number of copies
Cluster Management Commands:
certificate modify certificate resources.
cluster-info Display cluster information
top Display Resource (CPU/Memory/Storage) usage.
cordon sign node by unschedulable
uncordon sign node by schedulable
drain Drain node in preparation for maintenance
taint Update one or more node Upper taints
Troubleshooting and Debugging Commands:
describe Displays a specified resource perhaps group of resources details
logs Output container in pod Logs in
attach Attach To a running container
exec In a container Execute a command in
port-forward Forward one or more local ports to a pod
proxy Run a proxy reach Kubernetes API server
cp copy files and directories reach containers And copy from container files and directories.
auth Inspect authorization
Advanced Commands:
diff Diff live version against would-be applied version
apply By file name or standard input stream(stdin)Configure resources
patch use strategic merge patch Update the of a resource field(s)
replace adopt filename perhaps stdin Replace a resource
wait Experimental: Wait for a specific condition on one or many resources.
convert In different API versions Conversion profile
Settings Commands:
label Update on this resource labels
annotate Update the annotation of a resource
completion Output shell completion code for the specified shell (bash or zsh)
Other Commands:
alpha Commands for features in alpha
api-resources Print the supported API resources on the server
api-versions Print the supported API versions on the server, in the form of "group/version"
config modify kubeconfig file
plugin Provides utilities for interacting with plugins.
version output client and server Version information for
//Run an nginx of pod type, named nginx, and the inner type is deployment
[root@master ~]# kubectl create deployment nginx --image nginx
deployment.apps/nginx created
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-6799fc88d8-7wp8w 1/1 Running 0 24s
[root@master ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 28s
/Run an nginx of pod type, named nginx, and the inner type is deployment
[root@master ~]# kubectl create deployment nginx --image nginx
deployment.apps/nginx created
[root@master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx-6799fc88d8-7wp8w 1/1 Running 0 24s
[root@master ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 28s
//Edit using the edit command
[root@master ~]# kubectl edit deployment nginx
......
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
creationTimestamp: "2021-12-20T10:33:49Z"
generation: 1
labels:
app: test #Change to test
name: jj #Add name: jj
.....
//see
[root@master ~]# kubectl describe deploy nginx
Name: nginx
Namespace: default
CreationTimestamp: Tue, 21 Dec 2021 01:18:37 +0800
Labels: app=test #Can be added or modified
name=jj
Annotations: deployment.kubernetes.io/revision: 1
Selector: app=nginx
Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType: RollingUpdate
MinReadySeconds: 0
RollingUpdateStrategy: 25% max unavailable, 25% max surge
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: nginx
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
---- ------ ------
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: nginx-6799fc88d8 (1/1 replicas created)
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 2m51s deployment-controller Scaled up replica set nginx-6799fc88d8 to
Scal pods
$kubectl scale deployment ngin --replicas=2
view info IP of pods
$k get pods -o wide
view cluster infor
get namespace
Delete pod
$ k delete pod nginx1