首页 > 其他分享 >K8S基础-POD

K8S基础-POD

时间:2022-12-17 18:00:41浏览次数:36  
标签:kubectl run v1 基础 nginx POD K8S true pod

1.1 POD

1.1.1 创建一个pod

定义一个pod (分层使用两个空格,勿用tab键)

# vim nginx.yaml
apiVersion: v1 # 必选, API 的版本号
kind: Pod # 必选,类型 Pod
metadata: # 必选,元数据
  name: nginx # 必选,符合 RFC 1035 规范的 Pod 名称
spec: # 必选,用于定义 Pod 的详细信息
  containers: # 必选,容器列表
  - name: nginx # 必选,符合 RFC 1035 规范的容器名称
    image: nginx:1.15.12 # 必选,容器所用的镜像的地址
    ports: # 可选,容器需要暴露的端口号列表
    - containerPort: 80 # 端口号

创建pod

# kubectl create -f nginx.yaml
pod/nginx created

查看pod状态

# kubectl get po        ### 使用 po 或者 pod 都可以
NAME    READY   STATUS    RESTARTS   AGE
nginx   1/1     Running   0          47s

使用kubectl run 创建一个pod

[root@k8s-master03 ~]# kubectl run nginx-run --image=nginx:1.15.12
pod/nginx-run created

##使用--dry-run 创建

[root@k8s-master03 ~]# kubectl run nginx --image=nginx:1.15.12 -oyaml --dry-run > pod.yaml
W1217 17:17:26.985672 75520 helpers.go:622] --dry-run is deprecated and can be replaced with --dry-run=client.
[root@k8s-master03 ~]#

[root@k8s-master03 ~]# cat pod.yaml
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: nginx
  name: nginx
spec:
  containers:
  - image: nginx:1.15.12
    name: nginx
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

删除pod

[root@k8s-master03 ~]# kubectl delete -f nginx.yaml   ##method1 指定yaml删除
pod "nginx" deleted
[root@k8s-master03 ~]# kubectl get po
NAME        READY   STATUS    RESTARTS   AGE
nginx-run   1/1     Running   0          93s
[root@k8s-master03 ~]# kubectl delete po nginx-run    ##method2 指定pod NAME删除
pod "nginx-run" deleted
[root@k8s-master03 ~]# kubectl get po
No resources found in default namespace.

 

查看pod的所有资源信息

[root@k8s-master03 ~]# kubectl api-resources
NAME                              SHORTNAMES   APIVERSION                             NAMESPACED   KIND
bindings                                       v1                                     true         Binding
componentstatuses                 cs           v1                                     false        ComponentStatus
configmaps                        cm           v1                                     true         ConfigMap
endpoints                         ep           v1                                     true         Endpoints
events                            ev           v1                                     true         Event
limitranges                       limits       v1                                     true         LimitRange
namespaces                        ns           v1                                     false        Namespace
nodes                             no           v1                                     false        Node
persistentvolumeclaims            pvc          v1                                     true         PersistentVolumeClaim
persistentvolumes                 pv           v1                                     false        PersistentVolume
pods                              po           v1                                     true         Pod
podtemplates                                   v1                                     true         PodTemplate
replicationcontrollers            rc           v1                                     true         ReplicationController
resourcequotas                    quota        v1                                     true         ResourceQuota
secrets                                        v1                                     true         Secret
serviceaccounts                   sa           v1                                     true         ServiceAccount
services                          svc          v1                                     true         Service
mutatingwebhookconfigurations                  admissionregistration.k8s.io/v1        false        MutatingWebhookConfiguration
................

 

标签:kubectl,run,v1,基础,nginx,POD,K8S,true,pod
From: https://www.cnblogs.com/zhongyuping/p/16989279.html

相关文章

  • Linux基础之文件属性
    文件属性,就是ll,查出来的东西,每列的意义[root@web01mclind]#ls-lhi16817447-rw-r--r--.1rootroot9012月720:141.txt16815727-rw-r--r--.1rootroot938......
  • Linux基础之命令行及快捷键
    Linux命令行分析[root@stu-linux~]#root:登录的用户名stu-linux:主机名~:表示当前目录(当前位置),如果登录后切换了目录,这个地方也会变化,比如:[root@stu85-modeletc......
  • Linux基础命令之一
    1.查看IP地址ipa=ipaddress 2.关机重启reboot:重启poweroff:关机关机重启:shutdownshutdown可以有三个参数,一个是重启,一个是关机,一个是取消,后边跟时间就可以......
  • K8s-发布方式浅谈
    K8s-发布方式浅谈蓝绿发布环境存在两个版本,蓝版本和绿版本同时存在,部署新版本然后进行测试,将流量切到新版本,最终实际运行的只有一个版本(蓝/绿)。好处是无需停机,并......
  • 解决k8s中service暴露的端口使用公网ip无法访问
    背景在华为云服务器上使用kk工具安装k8s+kubesphere,正常安装后无法通过公网ip+端口号的方式访问kubesphere页面(ps:华为云上的安全组已经放开)解决办法在命令行执行iptable......
  • 算法基础课 第一章 基础算法
    1基础算法1.1快速排序核心思想-三步走确定分界点:q[l],q[(l+r)/2],q[r],随机调整区间递归处理C代码#include<stdio.h>constintN=1e5+5;intnum[N];v......
  • DDD学习笔记----基础知识(2)
    聚合:高内聚,低耦合。聚合内实体可以协同工作,聚合外实体可以低耦合工作。关系紧密的实体放到一个聚合中,每个聚合中有一个实体作为聚合根,所有对于聚合内对象的访问都能通过聚......
  • 『牛角书』鸿蒙基础计算器
    简介这是我自己的鸿蒙期末考查大作业,通过一学期课程的学习,研究出来的一些成果,代码还有很多需要优化的地方,本文内容仅为利用组件简单的计算器页面。成果展示开发思路计算器......
  • 前端开发系列102-小程序篇之小程序中的基础组件(四)
    title:前端开发系列102-小程序篇之小程序中的基础组件(四)tags:categories:[]date:2018-12-0800:00:09本文介绍小程序中的基础组件,主要包括form表单、radio和lab......
  • 前端开发系列101-小程序篇之小程序中的基础组件(三)
    title:前端开发系列101-小程序篇之小程序中的基础组件(三)tags:categories:[]date:2018-12-0700:00:09本文介绍小程序中的基础组件,主要包括swiper、scroll-view......