当前位置:网站首页>[cloud native learning notes] learn about kubernetes configuration list yaml file
[cloud native learning notes] learn about kubernetes configuration list yaml file
2022-06-24 21:14:00 【The night owl of the second dimension】
List of articles
Preface
Mentioned earlier When the application is deployed , In practical work, we use kubectl apply. This section describes the specific usage of these two commands , And the preparation of the configuration used with it .
One 、kubectl apply -f
-f yes kubectl apply The most common command options . Enter... By filename or console , Allocate resources . Accept JSON and YAML Format description file .YAML Format is more recommended .
-f, --filename=[]: File name containing configuration information , Directory name or URL.
Example :
# take pod.json The configuration in applies to pod
$ kubectl apply -f ./kube-config.yaml
# Input to the console JSON Configuration is applied to Pod
$ cat kube-config.yaml | kubectl apply -f -
Two 、k8s yaml The configuration file
About yaml I won't give you a specific introduction , The file suffix is usually .yaml perhaps .yml The syntax is as follows :
Case sensitive
Use indentation to indicate hierarchy
Indenting is not allowed tab, Only spaces are allowed
The number of indented spaces doesn't matter , Just align the elements at the same level to the left
'#' Notation
stay k8s In the configuration manifest file of , Need to master yaml Key value pairs and arrays in syntax . recommend yaml Introduction learning .
k8s Of yaml The configuration is mainly divided into four parts :
- apiVersion
- kind
- metadata
- spec
Such as pod resources yaml Example :
apiVersion: v1 # API Version number , Must be in `kubectl apiversion` in
kind: Pod # Specify the type of resource to create , The resource type can be Deployment、Service etc. , According to the actual situation .
metadata: # Metadata , Include some meta Information , Such as the name 、namespace、 Labels and other information .
name: nginx-test # The name of the resource , In the same namespace Must be unique in space
spec: # Resource specifications , Including some container,storage,volume And other things k8s Required parameters .
containers: # List of containers
- name: front-end # Container name
image: nginx # Container mirror
ports:
- containerPort: 80 # The external port of the container
1. apiVersion
To designate api Version number , It usually says v1, But it's not dead , It can be executed kubectl api-versions Command view , One of the .
$ kubectl api-versions
admissionregistration.k8s.io/v1
apiextensions.k8s.io/v1
apiregistration.k8s.io/v1
apps/v1
authentication.k8s.io/v1
authorization.k8s.io/v1
autoscaling/v1
autoscaling/v2
autoscaling/v2beta1
autoscaling/v2beta2
batch/v1
batch/v1beta1
certificates.k8s.io/v1
coordination.k8s.io/v1
discovery.k8s.io/v1
discovery.k8s.io/v1beta1
events.k8s.io/v1
events.k8s.io/v1beta1
flowcontrol.apiserver.k8s.io/v1beta1
flowcontrol.apiserver.k8s.io/v1beta2
networking.k8s.io/v1
node.k8s.io/v1
node.k8s.io/v1beta1
policy/v1
policy/v1beta1
rbac.authorization.k8s.io/v1
scheduling.k8s.io/v1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1
2. kind
It means that we should yaml Defined resource type ,k8s There are many kinds of resources in , Can execute orders kubectl api-resources -o wide see , But most of them are not often used . Common resources mainly include Deployment,Services,Job etc. .
$ kubectl api-resources -o wide
NAME SHORTNAMES APIVERSION NAMESPACED KIND VERBS
bindings v1 true Binding [create]
componentstatuses cs v1 false ComponentStatus [get list]
configmaps cm v1 true ConfigMap [create delete deletecollection get list patch update watch]
endpoints ep v1 true Endpoints [create delete deletecollection get list patch update watch]
events ev v1 true Event [create delete deletecollection get list patch update watch]
limitranges limits v1 true LimitRange [create delete deletecollection get list patch update watch]
namespaces ns v1 false Namespace [create delete get list patch update watch]
nodes no v1 false Node [create delete deletecollection get list patch update watch]
persistentvolumeclaims pvc v1 true PersistentVolumeClaim [create delete deletecollection get list patch update watch]
persistentvolumes pv v1 false PersistentVolume [create delete deletecollection get list patch update watch]
pods po v1 true Pod [create delete deletecollection get list patch update watch]
podtemplates v1 true PodTemplate [create delete deletecollection get list patch update watch]
replicationcontrollers rc v1 true ReplicationController [create delete deletecollection get list patch update watch]
resourcequotas quota v1 true ResourceQuota [create delete deletecollection get list patch update watch]
secrets v1 true Secret [create delete deletecollection get list patch update watch]
serviceaccounts sa v1 true ServiceAccount [create delete deletecollection get list patch update watch]
services svc v1 true Service [create delete deletecollection get list patch update watch]
mutatingwebhookconfigurations admissionregistration.k8s.io/v1 false MutatingWebhookConfiguration [create delete deletecollection get list patch update watch]
validatingwebhookconfigurations admissionregistration.k8s.io/v1 false ValidatingWebhookConfiguration [create delete deletecollection get list patch update watch]
customresourcedefinitions crd,crds apiextensions.k8s.io/v1 false CustomResourceDefinition [create delete deletecollection get list patch update watch]
apiservices apiregistration.k8s.io/v1 false APIService [create delete deletecollection get list patch update watch]
controllerrevisions apps/v1 true ControllerRevision [create delete deletecollection get list patch update watch]
daemonsets ds apps/v1 true DaemonSet [create delete deletecollection get list patch update watch]
deployments deploy apps/v1 true Deployment [create delete deletecollection get list patch update watch]
replicasets rs apps/v1 true ReplicaSet [create delete deletecollection get list patch update watch]
statefulsets sts apps/v1 true StatefulSet [create delete deletecollection get list patch update watch]
tokenreviews authentication.k8s.io/v1 false TokenReview [create]
localsubjectaccessreviews authorization.k8s.io/v1 true LocalSubjectAccessReview [create]
selfsubjectaccessreviews authorization.k8s.io/v1 false SelfSubjectAccessReview [create]
selfsubjectrulesreviews authorization.k8s.io/v1 false SelfSubjectRulesReview [create]
subjectaccessreviews authorization.k8s.io/v1 false SubjectAccessReview [create]
horizontalpodautoscalers hpa autoscaling/v2 true HorizontalPodAutoscaler [create delete deletecollection get list patch update watch]
cronjobs cj batch/v1 true CronJob [create delete deletecollection get list patch update watch]
jobs batch/v1 true Job [create delete deletecollection get list patch update watch]
certificatesigningrequests csr certificates.k8s.io/v1 false CertificateSigningRequest [create delete deletecollection get list patch update watch]
leases coordination.k8s.io/v1 true Lease [create delete deletecollection get list patch update watch]
endpointslices discovery.k8s.io/v1 true EndpointSlice [create delete deletecollection get list patch update watch]
events ev events.k8s.io/v1 true Event [create delete deletecollection get list patch update watch]
flowschemas flowcontrol.apiserver.k8s.io/v1beta2 false FlowSchema [create delete deletecollection get list patch update watch]
prioritylevelconfigurations flowcontrol.apiserver.k8s.io/v1beta2 false PriorityLevelConfiguration [create delete deletecollection get list patch update watch]
ingressclasses networking.k8s.io/v1 false IngressClass [create delete deletecollection get list patch update watch]
ingresses ing networking.k8s.io/v1 true Ingress [create delete deletecollection get list patch update watch]
networkpolicies netpol networking.k8s.io/v1 true NetworkPolicy [create delete deletecollection get list patch update watch]
runtimeclasses node.k8s.io/v1 false RuntimeClass [create delete deletecollection get list patch update watch]
poddisruptionbudgets pdb policy/v1 true PodDisruptionBudget [create delete deletecollection get list patch update watch]
podsecuritypolicies psp policy/v1beta1 false PodSecurityPolicy [create delete deletecollection get list patch update watch]
clusterrolebindings rbac.authorization.k8s.io/v1 false ClusterRoleBinding [create delete deletecollection get list patch update watch]
clusterroles rbac.authorization.k8s.io/v1 false ClusterRole [create delete deletecollection get list patch update watch]
rolebindings rbac.authorization.k8s.io/v1 true RoleBinding [create delete deletecollection get list patch update watch]
roles rbac.authorization.k8s.io/v1 true Role [create delete deletecollection get list patch update watch]
priorityclasses pc scheduling.k8s.io/v1 false PriorityClass [create delete deletecollection get list patch update watch]
csidrivers storage.k8s.io/v1 false CSIDriver [create delete deletecollection get list patch update watch]
csinodes storage.k8s.io/v1 false CSINode [create delete deletecollection get list patch update watch]
csistoragecapacities storage.k8s.io/v1beta1 true CSIStorageCapacity [create delete deletecollection get list patch update watch]
storageclasses sc storage.k8s.io/v1 false StorageClass [create delete deletecollection get list patch update watch]
volumeattachments storage.k8s.io/v1 false VolumeAttachment [create delete deletecollection get list patch update watch]
3. metadata
This field is for the resource object " identification ", Metadata , It's also from Kubernetes The main basis for finding this object . Include name 、namespace、 Information such as labels and notes .metadata Common subfields in are :
- name: Resource name , In the same namespace It has to be the only one .
- namespace: Namespace , An abstract collection of resources and objects , Yes k8s Divide logically , Achieve hierarchical management , There is a certain degree of resource and permission isolation . built-in namespace Yes default,kube-system and kube-public. The default value is default.
- label: Tag data , Can be used in spec Pass through selectors Match , Achieve binding effect .
- annotation: annotation , Some customized auxiliary information .
4. spec
spec It refers to the specification of resource content , That is, the state we expect our resources to achieve , The specifications and contents of various resources are not uniform , such as pod The contents of this article include container,volume,nodeSelector etc. .Deployment It includes replicas、selector、template etc. .
For a more comprehensive introduction to specific fields, please refer to spec Common fields and their meanings
边栏推荐
猜你喜欢

Sleep revolution - find the right length of rest

微信小程序中使用vant组件

Postman assertion

Haitai Advanced Technology | application of privacy computing technology in medical data protection

Summary of message protocol problems

Basic database syntax learning

大厂出海,败于“姿态”

Grating diffraction

How Fiddler works

Background of master data construction
随机推荐
Nifi quick installation (stand-alone / cluster)
Realization of truth table assignment by discrete mathematical programming
DHCP operation
Tool composition in JMeter
An example illustrates restful API
Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
Leetcode(455)——分发饼干
全上链哈希游戏dapp系统定制(方案设计)
regular expression
Background of master data construction
Sleep revolution - find the right length of rest
Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably
Where is 5g really powerful? What is the difference with 4G?
在Dialog中使用透明的【X】叉叉按钮图片
JUnit unit test
Variable setting in postman
Geek University cloud native training camp
Talking about the range of data that MySQL update will lock
Microsoft Certification (dynamic 365) test
What will you do if you have been ignored by your leaders at work?