日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

3. Kubernetes资源-概述

發布時間:2024/1/8 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 3. Kubernetes资源-概述 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

3. Kubernetes資源-概述

3.1 資源概念

Kubernetes中所有內容都抽象為資源,資源實例化之后叫做對象。Kubernetes的資源根據不同的維度可以分為:

  • 工作負載型:Pod、ReplicaSet、Deployment、DaemonSet、Job/CronJob、StatefulSet
  • 服務發現型:Service、Ingress
  • 配置與存儲:ConfigMap、Secret、Volume、PV-PVC
  • 集群級別:Namespace、Role、ClusterRole、RoleBinding、ClusterRoleBinding
  • 元數據型:HPA、PodTemplate、LimitRangs

3.2 資源清單

Kubernetes中一般使用YAML格式的文件來創建符合預期期望的Pod,這樣的YAML文件稱為資源清單。可以使用kubectl explain RESOURCE [options]查看不同資源支持的YAML標簽。例如:查看Pod資源所支持的標簽

[root@k8smaster43-11 CSDN]# kubectl explain pod KIND: Pod VERSION: v1DESCRIPTION:Pod is a collection of containers that can run on a host. This resource iscreated by clients and scheduled onto hosts.FIELDS:apiVersion <string>APIVersion defines the versioned schema of this representation of anobject. Servers should convert recognized schemas to the latest internalvalue, and may reject unrecognized values. More info:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resourceskind <string>Kind is a string value representing the REST resource this objectrepresents. Servers may infer this from the endpoint the client submitsrequests to. Cannot be updated. In CamelCase. More info:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kindsmetadata <Object>Standard object's metadata. More info:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadataspec <Object>Specification of the desired behavior of the pod. More info:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-statusstatus <Object>Most recently observed status of the pod. This data may not be up to date.Populated by the system. Read-only. More info:https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status[root@k8smaster43-11 CSDN]#

3.2.1 YAML

  • YAML文件使用#標識注釋,只支持空格縮進,并且相同層級的元素左對齊;
  • YAML數據支持對象(鍵值對)、數組和純量(字符串、布爾、整數、浮點數、空值、時間、日期)。
  • 3.2.2 創建資源(自主式Pod為例)

  • 編寫YAML文件:
  • apiVersion: v1 # API版本 kind: Pod # 資源類型 metadata:name: tomcat-pod # Pod資源名稱namespace: default # Pod所在名稱空間labels:app: tomcat # Pod資源標簽 spec:containers:- name: tomcat # Pod內容器名稱image: tomcat:8.0 # Pod內容器鏡像imagePullPolicy: Neverports:- containerPort: 8080 # Pod內容器服務端口hostPort: 8080 # 主機映射端口protocol: TCP # 端口服務類型
  • 創建Pod資源:
  • [root@k8smaster43-11 CSDN]# kubectl create -f pod.yaml pod/tomcat-pod created [root@k8smaster43-11 CSDN]#
  • 查看Pod資源:
  • [root@k8smaster43-11 CSDN]# kubectl get pod -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES tomcat-pod 1/1 Running 0 2m58s 10.244.1.53 k8sworker43-21 <none> <none>
  • 查看資源詳情:
  • [root@k8smaster43-11 CSDN]# kubectl describe pod/tomcat-pod Name: tomcat-pod Namespace: default Priority: 0 Node: k8sworker43-21/192.168.43.21 Start Time: Sat, 23 Jul 2022 08:08:49 +0800 Labels: app=tomcat Annotations: <none> Status: Running IP: 10.244.1.53 IPs:IP: 10.244.1.53 Containers:tomcat:Container ID: docker://81e61ed10151b679bc987f388422372d4bff66eae7ba4246ed064d0035d6ac22Image: tomcat:8.0Image ID: docker-pullable://tomcat@sha256:8ecb10948deb32c34aeadf7bf95d12a93fbd3527911fa629c1a3e7823b89ce6fPort: 8080/TCPHost Port: 8080/TCPState: RunningStarted: Sat, 23 Jul 2022 08:08:50 +0800Ready: TrueRestart Count: 0Environment: <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from default-token-sbvk4 (ro) Conditions:Type StatusInitialized True Ready True ContainersReady True PodScheduled True Volumes:default-token-sbvk4:Type: Secret (a volume populated by a Secret)SecretName: default-token-sbvk4Optional: false 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:Type Reason Age From Message---- ------ ---- ---- -------Normal Scheduled 5m49s default-scheduler Successfully assigned default/tomcat-pod to k8sworker43-21Normal Pulled 5m45s kubelet Container image "tomcat:8.0" already present on machineNormal Created 5m45s kubelet Created container tomcatNormal Started 5m45s kubelet Started container tomcat [root@k8smaster43-11 CSDN]#
  • 刪除Pod資源:
  • [root@k8smaster43-11 CSDN]# kubectl delete -f pod.yaml pod "tomcat-pod" deleted [root@k8smaster43-11 CSDN]#

    總結

    以上是生活随笔為你收集整理的3. Kubernetes资源-概述的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。