美文网首页
k8s其他命令

k8s其他命令

作者: 小圆圈Belen | 来源:发表于2020-08-26 22:53 被阅读0次

具体命令详解:

1.基础命令:
https://www.jianshu.com/p/d2fe32fd4675
2.设置命令:
https://www.jianshu.com/p/97f71c8ec720
3.部署命令:
https://www.jianshu.com/p/43a5d6bd1b67
4.集群管理命令:
https://www.jianshu.com/p/f7a0b418eeac
5.集群故障排查和调试命令:
https://www.jianshu.com/p/c03f3799e3ab
6.其他命令:
https://www.jianshu.com/p/c069c799a6c1

k8s简介及其他命令:https://www.jianshu.com/p/af292dc4a832

1.api-servions命令:打印受支持的api版本信息

# kubectl api-versions
[root@master ~]# kubectl api-versions
admissionregistration.k8s.io/v1beta1
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1beta1
apps/v1
apps/v1beta1
apps/v1beta2
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2beta1
batch/v1
batch/v1beta1
certificates.k8s.io/v1beta1
events.k8s.io/v1beta1
extensions/v1beta1
networking.k8s.io/v1
policy/v1beta1
rbac.authorization.k8s.io/v1
rbac.authorization.k8s.io/v1beta1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

2.help命令:用于查看命令帮助
3.config:用于修改kubeconfig配置文件(用于访问api,例如配置认证信息)
4.version命令:打印客户端和服务端版本信息

[root@master ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.3", GitCommit:"2d3c76f9091b6bec110a5e63777c332469e0cba2", GitTreeState:"clean", BuildDate:"2019-08-19T11:13:54Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.0", GitCommit:"925c127ec6b946659ad0fd596fa959be43f0cc05", GitTreeState:"clean", BuildDate:"2017-12-15T20:55:30Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"linux/amd64"}

5.plugin命令:运行一个命令行插件
6.apply命令: 通过文件名或者标准输入对资源应用配置

通过文件名或控制台输入,对资源进行配置。 如果资源不存在,将会新建一个。可以使用 JSON 或者 YAML 格式。

# 语法
kubectl apply -f FILENAME

# 将pod.json中的配置应用到pod
kubectl apply -f ./pod.json
# 将控制台输入的JSON配置应用到Pod
cat pod.json | kubectl apply -f -

选项
-f, --filename=[]: 包含配置信息的文件名,目录名或者URL。
      --include-extended-apis[=true]: If true, include definitions of new APIs via calls to the API server. [default true]
  -o, --output="": 输出模式。"-o name"为快捷输出(资源/name).
      --record[=false]: 在资源注释中记录当前 kubectl 命令。
  -R, --recursive[=false]: Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
      --schema-cache-dir="~/.kube/schema": 非空则将API schema缓存为指定文件,默认缓存到'$HOME/.kube/schema'
      --validate[=true]: 如果为true,在发送到服务端前先使用schema来验证输入。

7.patch命令: 使用补丁修改,更新资源的字段,也就是修改资源的部分内容

# 语法
kubectl patch (-f FILENAME | TYPE NAME) -p PATCH

# Partially update a node using strategic merge patch
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
# Update a container's image; spec.containers[*].name is required because it's a merge key
kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'

8.replace命令: 通过文件或者标准输入替换原有资源

# 语法
kubectl replace -f FILENAME

# Replace a pod using the data in pod.json.
kubectl replace -f ./pod.json
# Replace a pod based on the JSON passed into stdin.
cat pod.json | kubectl replace -f -
# Update a single-container pod's image version (tag) to v4
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
# Force replace, delete and then re-create the resource
kubectl replace --force -f ./pod.json

9.convert命令: 不同的版本之间转换配置文件

# 语法
kubectl convert -f FILENAME

# Convert 'pod.yaml' to latest version and print to stdout.
kubectl convert -f pod.yaml
# Convert the live state of the resource specified by 'pod.yaml' to the latest version
# and print to stdout in json format.
kubectl convert -f pod.yaml --local -o json
# Convert all files under current directory to latest version and create them all.
kubectl convert -f . | kubectl create -f -

相关文章

  • k8s其他命令

    具体命令详解: 1.基础命令:https://www.jianshu.com/p/d2fe32fd46752.设置...

  • K8S命令的梳理

    K8S命令的梳理 kubectl是一个基础的K8S集群管理命令,可以实现对K8S资源的查询,创建,删除,更新,回退...

  • kubectl命令

    kubectl命令 command:子命令,用于操作k8s集群资源对象的命令,例如create、delete、de...

  • k8s之kubectl命令自动补全

    k8s 命令自动补全 或者 在mac上

  • k8s说明

    k8s核心组件 k8s架构图 k8s扩展功能 开启XSHELL的多终端执行命令 kubernetes在centos...

  • 第3课 Kubectl常用命令详解

    摘要 本文介绍k8s集群管理命令Kubectl分类和命令详解。 内容 1. kubectl命令列表分类 (1)Ba...

  • 其他命令

    自学整理记录,大神见笑 目录 find ln 1.查找文件→find find reddington -name ...

  • 其他命令

    1查找文件find [路径] -name '.py查找指定路径下扩展名是.py的文件,包括子目录。find Des...

  • Docker 体验及总结(7) - 容器集群监控(待续)

    单一容器监控 容器监控命令 weavescope图形化工具 K8S容器监控 K8S集群可使用Heapster + ...

  • K8S原理(重要)

    1、用K8S部署Nginx 2、K8S 核心架构原理 3、常用命令 4、k8s中各端口说明 5、用yaml创建de...

网友评论

      本文标题:k8s其他命令

      本文链接:https://www.haomeiwen.com/subject/qjcqsktx.html