当前位置: 首页 > news >正文

做网页的网站优质的武进网站建设

做网页的网站,优质的武进网站建设,网站建设 交单流程,网站开发相关书籍Kubernetes集群客户端工具kubectl 我们已经能够部署Kubernetes了,那么我们如何使用Kubernetes集群运行企业的应用程序呢?那么,我们就需要使用命令行工具kubectl。 kubectl就是控制Kubernetes的驾驶舱,它允许你执行所有可能的Kube…

Kubernetes集群客户端工具kubectl

我们已经能够部署Kubernetes了,那么我们如何使用Kubernetes集群运行企业的应用程序呢?那么,我们就需要使用命令行工具kubectl。

kubectl就是控制Kubernetes的驾驶舱,它允许你执行所有可能的Kubernetes操作,从技术角度来看,Kubectl就是Kubernetes API的一个客户端而已。

Kubernetes API 是一个 HTTP REST API 服务,该 API 服务才是 Kubernetes 的真正用到的用户接口,所以 Kubernetes 通过该 API 进行实际的控制。这也就意味着每个 Kubernetes 的操作都会通过 API 端点暴露出去,当然也就可以通过对这些 API 端口进行 HTTP 请求来执行相应的操作。所以,kubectl 最主要的工作就是执行 Kubernetes API 的 HTTP 请求。

 

学习目标:

了解kubectl 命令帮助方法

了解kubectl子命令使用分类

课程内容:

1、kubectl帮助方法:

我们预先是在所有节点上安装了kubectl工具。

# 检查kubectl是否安装:
[root@master1 ~]# rpm -qa |grep kubectl
kubectl-1.21.10-0.x86_64
[root@master1 ~]## 获取kubectl帮助方法:
[root@master1 ~]# kubectl --help
kubectl controls the Kubernetes cluster manager.Find more information at:
https://kubernetes.io/docs/reference/kubectl/overview/Basic Commands (Beginner):create        Create a resource from a file or from stdin.expose        Take a replication controller, service, deployment or pod and
expose it as a new Kubernetes Servicerun           Run a particular image on the clusterset           Set specific features on objectsBasic Commands (Intermediate):explain       Documentation of resourcesget           Display one or many resourcesedit          Edit a resource on the serverdelete        Delete resources by filenames, stdin, resources and names, or by
resources and label selectorDeploy Commands:rollout       Manage the rollout of a resourcescale         Set a new size for a Deployment, ReplicaSet or Replication
Controllerautoscale     Auto-scale a Deployment, ReplicaSet, StatefulSet, or
ReplicationControllerCluster Management Commands:certificate   Modify certificate resources.cluster-info  Display cluster infotop           Display Resource (CPU/Memory) usage.cordon        Mark node as unschedulableuncordon      Mark node as schedulabledrain         Drain node in preparation for maintenancetaint         Update the taints on one or more nodesTroubleshooting and Debugging Commands:describe      Show details of a specific resource or group of resourceslogs          Print the logs for a container in a podattach        Attach to a running containerexec          Execute a command in a containerport-forward  Forward one or more local ports to a podproxy         Run a proxy to the Kubernetes API servercp            Copy files and directories to and from containers.auth          Inspect authorizationdebug         Create debugging sessions for troubleshooting workloads and
nodesAdvanced Commands:diff          Diff live version against would-be applied versionapply         Apply a configuration to a resource by filename or stdinpatch         Update field(s) of a resourcereplace       Replace a resource by filename or stdinwait          Experimental: Wait for a specific condition on one or many
resources.kustomize     Build a kustomization target from a directory or URL.Settings Commands:label         Update the labels on a resourceannotate      Update the annotations on a resourcecompletion    Output shell completion code for the specified shell (bash or
zsh)Other Commands:api-resources Print the supported API resources on the serverapi-versions  Print the supported API versions on the server, in the form of
"group/version"config        Modify kubeconfig filesplugin        Provides utilities for interacting with plugins.version       Print the client and server version informationUsage:kubectl [flags] [options]Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all
commands).

kubectl子命令使用分类:

列出所有pod并显示详细信息

[root@master1 ~]# kubectl get pods -o wide
NAME                     READY   STATUS    RESTARTS   AGE   IP           NODE      NOMINATED NODE   READINESS GATES
nginx-65c4bffcb6-gd9z6   1/1     Running   0          8h    10.244.1.4   worker1   <none>           <none>

查看所有deployment对象。

[root@master1 ~]# kubectl get deployment nginx
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   1/1     1            1           9h

查看所有service对象:

[root@master1 ~]# kubectl get svc
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        10h
nginx        NodePort    10.101.138.1   <none>        80:30831/TCP   9h
[root@master1 ~]#
[root@master1 ~]#
[root@master1 ~]# kubectl get service
NAME         TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1      <none>        443/TCP        10h
nginx        NodePort    10.101.138.1   <none>        80:30831/TCP   9h

查看不同namespace下的Pod对象:

[root@master1 ~]# kubectl get pods -n default
NAME                     READY   STATUS    RESTARTS   AGE
nginx-65c4bffcb6-gd9z6   1/1     Running   0          9h[root@master1 ~]# kubectl get pods --all-namespaces
NAMESPACE      NAME                                       READY   STATUS    RESTARTS   AGE
default        nginx-65c4bffcb6-gd9z6                     1/1     Running   0          9h
kube-flannel   kube-flannel-ds-dvjnd                      1/1     Running   0          9h
kube-flannel   kube-flannel-ds-gxl4h                      1/1     Running   0          9h
kube-flannel   kube-flannel-ds-jvdzc                      1/1     Running   0          9h
kube-system    calico-kube-controllers-594649bd75-xjbgr   1/1     Running   0          9h
kube-system    calico-node-6lz45                          1/1     Running   0          9h
kube-system    calico-node-fdprn                          1/1     Running   0          9h
kube-system    calico-node-szs6x                          1/1     Running   0          9h
kube-system    coredns-558bd4d5db-fmrpg                   1/1     Running   0          10h
kube-system    coredns-558bd4d5db-fnxdn                   1/1     Running   0          10h
kube-system    etcd-master1                               1/1     Running   1          10h
kube-system    kube-apiserver-master1                     1/1     Running   1          10h
kube-system    kube-controller-manager-master1            1/1     Running   1          10h
kube-system    kube-proxy-rz26h                           1/1     Running   0          9h
kube-system    kube-proxy-spf9t                           1/1     Running   1          9h
kube-system    kube-proxy-x4fq5                           1/1     Running   0          10h
kube-system    kube-scheduler-master1                     1/1     Running   1          10h

查看资源描述:

[root@master1 ~]# kubectl describe pods
Name:         nginx-65c4bffcb6-gd9z6
Namespace:    default
Priority:     0
Node:         worker1/192.168.17.147
Start Time:   Sat, 06 Apr 2024 19:04:43 +0800
Labels:       app=nginxpod-template-hash=65c4bffcb6
Annotations:  <none>
Status:       Running
IP:           10.244.1.4
IPs:IP:           10.244.1.4
Controlled By:  ReplicaSet/nginx-65c4bffcb6
Containers:nginx:Container ID:   docker://b0860e41573587a5c065c9aa18c398475b1b31f9f56d7d3c2e04171f80f1e1c1Image:          nginx:1.14-alpineImage ID:       docker-pullable://nginx@sha256:485b610fefec7ff6c463ced9623314a04ed67e3945b9c08d7e53a47f6d108dc7Port:           <none>Host Port:      <none>State:          RunningStarted:      Sat, 06 Apr 2024 19:05:04 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mjhtz (ro)
Conditions:Type              StatusInitialized       TrueReady             TrueContainersReady   TruePodScheduled      True
Volumes:kube-api-access-mjhtz:Type:                    Projected (a volume that contains injected data from multiple sources)TokenExpirationSeconds:  3607ConfigMapName:           kube-root-ca.crtConfigMapOptional:       <nil>DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300snode.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>

所有的命令都要熟练使用。

使用kubectl命令必要环境:

在worker节点如何使用kubectl命令管理K8s集群?

准备集群管理配置文件:

mkdir .kube
scp master1:/root/.kube/config .kube/

使用命令验证:

[root@worker1 ~]# kubectl get nodes
NAME      STATUS   ROLES                  AGE   VERSION
master1   Ready    control-plane,master   10h   v1.21.10
worker1   Ready    <none>                 10h   v1.21.10
worker2   Ready    <none>                 10h   v1.21.10

其中这个config的配置文件:

这是一个连接Kubernetes API (IP地址+端口),就能管理到集群。

 

http://www.ijyty.com/news/268891.html

相关文章:

  • 贵阳市网站开发网络项目方案设计
  • 网站底部分享怎么做wordpress评论者头像
  • 网站开发技术发展趋势网站建设工作简介
  • 为网站网站做代理被判缓刑建设网站需要什么证件
  • 网站 关键词 出现频率wordpress 知言
  • 品牌创意网站建设什么是网络营销?常见的网络营销方式有哪些?
  • app开发和网站开发哪个好成都旅游公司排名前十
  • 怎样自己创造网站aso推广公司
  • 扬州做网站公司邵阳市住房和城乡建设局网站
  • 网站怎么设关键词注册一个网站
  • 微商城网站开发网站域名已经解析但没有被百度等搜索引擎收录怎么办
  • 网站模版上线需要什么意思怎么做小程序推广
  • 做ppt的网站有哪些内容wordpress 媒体插件
  • Java异常处理机制:构建健壮的应用程序!
  • Java(day257):Java 中如何实现分布式锁
  • Vue 中如何使用 async 和 await 实现异步操作
  • 你也想做一个全栈开发者吗?从零到一的开发之路竟然这么有趣!
  • 装修网站建设价格wordpress访问局域网
  • 网站开发文档 php做网站的要到处跑吗
  • 房地产做网站不wordpress 视频显示图片
  • iis建立网站企业运营管理名词解释
  • 京山网站设计公司如果做公司网站
  • 网站域名注册的相关证书证明文件高埗仿做网站
  • 网站首页动画模板zac seo博客
  • 郴州网站优化公司教务系统管理系统
  • 闸北网站建设公司平面设计公司属于什么行业
  • 网站开发哪家公司口碑好手机网站建设的行情
  • 怎么做网站的搜索功能浙江网站开发工程师
  • 网站seo视频教程不花钱的做网站
  • 杭州做网站设计公司重庆 网站定制