1. Define a yml file: nginx.pod.yml:

apiVersion: v1
kind: Pod
metadata:
name: my-nginx
labels:
app: nginx
rel: stable spec:
containers:
- name: my-nginx
image: nginx:alpine
ports:
- containerPort: 80
resources:

It creates my-nginx pod.

2. We the yml file with kubectl:

kubectl create -f nginx.pod.yml --save-config   

We use '--save-config' option.

If we run:

kubectl get pods my-nginx -o yaml

It outpus the configurations for my-nginx pod:

...
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"app":"nginx","rel":"stable"},"name":"my-nginx","namespace":"default"},"spec":{"containers":[{"image":"nginx:alpine","name":"my-nginx","ports":[{"containerPort":80}],"resources":null}]}}
...

It save the the configuration for this pod, so later if I udpated the yml file, it will diff the changes, and only apply the changes to the pod.

3. apply vs create:

kubectl apply -f nginx.pod.yml  // pod/my-nginx configured

The nice thing of 'apply' is: if the pod is not there, it will create the resource, if the pod is there, then it will update the resource.

4. Get into the pod:

kubectl exec my-nginx -it sh

Quite you can type:

exit

5. Delete the pod:

This time actually we only have pod, without develoyment, so we can delete the pod by:

kubectl delete pod my-nginx
kubectl delete -f nginx.pod.yml

[Kubernetes] Defining a Pod with YAML的更多相关文章

  1. Kubernetes — 深入解析Pod对象:基本概念(一)

    在上一篇文章中,我详细介绍了 Pod 这个 Kubernetes 项目中最重要的概念. 现在,你已经非常清楚:Pod,而不是容器,才是 Kubernetes 项目中的最小编排单位.将这个设计落实到 A ...

  2. Kubernetes — 深入解析Pod对象:基本概念(二)

    作为 Kubernetes 项目里最核心的编排对象,Pod 携带的信息非常丰富.其中,资源定义(比如 CPU.内存等),以及调度相关的字段.在本篇,我们就先从一种特殊的 Volume 开始,来帮助你更 ...

  3. [Kubernetes]深入解析Pod对象

    k8s集群搭建是比较容易的,但是我们为什么要搭建,里面涉及到的内容,我们为什么需要? 这篇文章就尝试来讲讲,我们为什么需要一个Pod,对Pod对象来一个深入解析. 我们为什么需要Pod 我们先来谈一个 ...

  4. kubernetes集群pod使用tc进行网络资源限额

    kubernetes集群pod使用tc进行网络资源限额 Docker容器可以实现CPU,内存,磁盘的IO限额,但是没有实现网络IO的限额.主要原因是在实际使用中,构建的网络环境是往超级复杂的大型网络. ...

  5. Kubernetes对象之Pod

    系列目录 Pod是Kubernetes调度的最小单元.一个Pod可以包含一个或多个容器,因此它可以被看作是内部容器的逻辑宿主机.Pod的设计理念是为了支持多个容器在一个Pod中共享网络和文件系统 因此 ...

  6. [Kubernetes]深入解析Pod

    Pod是Kubernetes项目的原子调度单位 为什么需要Pod? 容器是未来云计算系统中的进程,容器镜像就是这个系统里的".exe"安装包,那Kubernetes就是操作系统. ...

  7. Kubernetes K8S之Pod跨namespace名称空间访问Service服务

    Kubernetes的两个Service(ServiceA.ServiceB)和对应的Pod(PodA.PodB)分别属于不同的namespace名称空间,现需要PodA和PodB跨namespace ...

  8. Kubernetes 实战 —— 03. pod: 运行于 Kubernetes 中的容器

    介绍 pod P53 pod 是 Kubernetes 中最为重要的核心概念,而其他对象仅仅用于 pod 管理. pod 暴露或被 pod 使用. pod 是一组并置的容器,代表了 Kubernete ...

  9. Kubernetes部署单元-Pod

    在 k8s 搞出 pod 概念的时候,其实 docker 官方就已经推出自己的容器编排应用 swarm.这一套服务可以帮助在不同节点上的容器,进行统一的管理,主要针对容器的启停,运维,还有部署,注意我 ...

随机推荐

  1. Spring+SpringMVC+MyBatis集成(SSM)

    1.导入需要用到的jar包 <dependencies> <!--Spring核心包--> <dependency> <groupId>org.spri ...

  2. Word 自带公式编写多行公式时在任意位置对齐 -- 含视频教程(10)

    1. 方法1:表格法之利用"点"运算符对齐(简单) 以下百度经验是我自己写的,不想放在上边了,移到这里. 2. 方法2:表格法之制表位对齐法(复杂) 未完 ...... 点击访问原 ...

  3. 【C++札记】const关键字

    C++中const关键字无处不在,我这里做下汇总,作为工具文章方便翻阅. 一:修饰数据成员 修饰的成员一单定义初始化后不能再进行修改,如: const int a = 10; a =20; //重新赋 ...

  4. Django框架深入了解_02(DRF之序列化、反序列化)

    序列化:将Python对象准换成json格式的字符串,反之即为反序列化 DRF的序列化使用过程: 使用drf的序列化组件 -1 新建一个序列化类继承Serializer -2 在类中写要序列化的字段 ...

  5. es6新特性-解构表达式、Lambda表达式、局部变量及map/reduce方法

    循环内的变量在循环外可见,不合理: let定义的变量是局部变量: const修饰的是常量,不允许再次修改,类似于java中的static: 解构表达式:

  6. 2.NioEventLoop的创建

    NioEventLoop的创建 NioEventLoop是netty及其重要的组成部件,它的首要职责就是为注册在它上的channels服务,发现这些channels上发生的新连接.读写等I/O事件,然 ...

  7. Codeforces VP/补题小记 (持续填坑)

    Codeforces VP/补题小记 1149 C. Tree Generator 给你一棵树的括号序列,每次交换两个括号,维护每次交换之后的直径. ​ 考虑括号序列维护树的路径信息和,是将左括号看做 ...

  8. Helm命令帮助参数

    # helm help The Kubernetes package manager To begin working with Helm, run the 'helm init' command: ...

  9. azkban从编译开始安装

    从git上下载最新的azkban稳定版代码 git clone https://github.com/azkaban/azkaban.git -b 3.74.3 这里还有个问题,如何把这个代码放到自己 ...

  10. flutter 动画 practice

    import 'package:flutter/material.dart'; import 'dart:io'; import 'dart:async'; main() => runApp(M ...