K8S 创建 Pod
1、通过 资源清单文件 yamlkubectl apply -f create-pod.yaml# 内容apiVersion: v1kind: Podmetadata:name: pod1spec:containers:- name: nginx-podimage: nginxports:- name: nginxportcontainerPort: 802、创建 podkubectl apply
·
一、通过命令行创建
kubectl run nginx --image=nginx --port=80
二、通过 资源清单文件 创建
1、创建 yaml
kubectl apply -f create-pod.yaml
# 内容
apiVersion: v1
kind: Pod
metadata:
name: pod1
spec:
containers:
- name: nginx-pod
image: nginx
ports:
- name: nginxport
containerPort: 80
2、创建 pod
kubectl apply -f create-pod.yaml
3、查看 pod
[root@master yaml]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod1 1/1 Running 0 2m3s 10.244.1.11 node1 <none> <none>
4、查看Pod可用的配置项
kubectl explain pod
# 结果
KIND: Pod
VERSION: v1
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is
created by clients and scheduled onto hosts.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata <Object>
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec <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-status
status <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
5、查看更多
kubectl explain pod.spec.containers
更多推荐



所有评论(0)