kubectl get - list resources
kubectl describe - show detailed information about a resource
kubectl logs - print the logs from a container in a pod
kubectl exec - execute a command on a container in a pod

2.docker给镜像改名
docker tag 8fa56d18961f k8s.gcr.io/kube-proxy:v1.13.0
docker rmi 10.10.31.205/k8s/kube-proxy:v1.13.0
docker tag d82530ead066 k8s.gcr.io/kube-controller-manager:v1.13.0
docker rmi 10.10.31.205/k8s/kube-controller-manager:v1.13.0
docker tag 9508b7d8008d k8s.gcr.io/kube-scheduler:v1.13.0
docker rmi 10.10.31.205/k8s/kube-scheduler:v1.13.0
docker tag f1ff9b7e3d6e k8s.gcr.io/kube-apiserver:v1.13.0
docker rmi 10.10.31.205/k8s/kube-apiserver:v1.13.0
docker tag f59dcacceff4 k8s.gcr.io/coredns:1.2.6
docker rmi 10.10.31.205/k8s/coredns:1.2.6
docker tag 3cab8e1b9802 k8s.gcr.io/etcd:3.2.24
docker rmi 10.10.31.205/k8s/etcd:3.2.24
docker tag 0dab2435c100 k8s.gcr.io/kubernetes-dashboard-amd64:v1.10.0
docker rmi 10.10.31.205/k8s/kubernetes-dashboard-amd64:v1.10.0
docker tag f0fad859c909 k8s.gcr.io/flannel:v0.10.0-amd64
docker rmi 10.10.31.205/k8s/flannel:v0.10.0-amd64
docker tag da86e6ba6ca1 k8s.gcr.io/pause:3.1
docker rmi 10.10.31.205/k8s/pause:3.1

3.Create a new service
kubectl get pods: look for existing Pods
kubectl get services: list the current Services from our cluster

kubectl expose deployment/kubernetes-bootcamp --type=“NodePort” --port 8080: To create a new service and expose it to external traffic we’ll use the expose command with NodePort as parameter (minikube does not support the LoadBalancer option yet).

kubectl describe services/kubernetes-bootcamp: To find out what port was opened externally (by the NodePort option)

export NODE_PORT= ( k u b e c t l g e t s e r v i c e s / k u b e r n e t e s − b o o t c a m p − o g o − t e m p l a t e = ′ ( i n d e x . s p e c . p o r t s 0 ) . n o d e P o r t ′ ) e c h o N O D E P O R T = (kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}') echo NODE_PORT= (kubectlgetservices/kubernetes−bootcamp−ogo−template=′(index.spec.ports0).nodePort′)echoNODEP​ORT=NODE_PORT: Create an environment variable called NODE_PORT that has the value of the Node port assigned

curl ( m i n i k u b e i p ) : (minikube ip): (minikubeip):NODE_PORT: test that the app is exposed outside of the cluster using curl, the IP of the Node and the externally exposed port

4.Using labels
The Deployment created automatically a label for our Pod. With describe deployment command you can see the name of the label:

kubectl describe deployment

Let’s use this label to query our list of Pods. We’ll use the kubectl get pods command with -l as a parameter, followed by the label values:

kubectl get pods -l run=kubernetes-bootcamp

You can do the same to list the existing services:

kubectl get services -l run=kubernetes-bootcamp

Get the name of the Pod and store it in the POD_NAME environment variable:

export POD_NAME=$(kubectl get pods -o go-template --template ‘{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}’)
echo Name of the Pod: $POD_NAME

To apply a new label we use the label command followed by the object type, object name and the new label:

kubectl label pod $POD_NAME app=v1

This will apply a new label to our Pod (we pinned the application version to the Pod), and we can check it with the describe pod command:

kubectl describe pods $POD_NAME

We see here that the label is attached now to our Pod. And we can query now the list of pods using the new label:

kubectl get pods -l app=v1

And we see the Pod.

  1. Deleting a service
    To delete Services you can use the delete service command. Labels can be used also here:

kubectl delete service -l run=kubernetes-bootcamp

Confirm that the service is gone:

kubectl get services

This confirms that our Service was removed. To confirm that route is not exposed anymore you can curl the previously exposed IP and port:

curl ( m i n i k u b e i p ) : (minikube ip): (minikubeip):NODE_PORT

This proves that the app is not reachable anymore from outside of the cluster. You can confirm that the app is still running with a curl inside the pod:

kubectl exec -ti $POD_NAME curl localhost:8080

We see here that the application is up.

19.k8s官方文档相关推荐

  1. k8s多master建议用几个_Kubernetes 教程之跟着官方文档从零搭建 K8S

    前言 本文将带领读者一起, 参照者 Kubernetes 官方文档, 对其安装部署进行讲解. Kubernetes 更新迭代很快, 书上.网上等教程可能并不能适用于新版本, 但官方文档能. 阅读这篇文 ...

  2. Kubernetes教程之跟着官方文档从零搭建K8S

    本文将带领读者一起, 参照着 Kubernetes 官方文档,对其安装部署进行讲解.Kubernetes更新迭代很快,书上.网上等教程可能并不能适用于新版本,但官方文可以. Kubernetes 教程 ...

  3. 【kubernetes/k8s概念】Kubernetes1.12从零开始(初):课程介绍与官方文档汇总

    说明 资料和交流方式 Kubernetes的文档介绍 Kubernetes中的术语与资源的操作方法 Kubernetes的API约定与启用方法 Kubernetes中资源(Object)的定义 kub ...

  4. 使用cephadm部署单节点ceph集群,后期可扩容(基于官方文档,靠谱,读起来舒服)

    目录 ceph各种部署工具比较(来自官方文档的翻译,靠谱!) 材料准备 cephadm使用条件 服务器有外网访问能力 服务器没有外网访问能力 安装cephadm cephadm的功能 两种安装方式 基 ...

  5. 文件标识符必须为双精度类型的整数值标量_【翻译】VTK官方文档 - vtk文件格式

    本文翻译自vtk官方文档:vtk_file_format 文末有链接 VTK提供了许多源对象和编写器对象,用于读取和写入流行的数据文件格式,此外,VTK也提供了自己的文件格式.创建一种数据文件格式的主 ...

  6. spark官方文档_Apache Spark 文档传送门

    新手会对官方文档比较陌生,不知道从何入手,下面整理基于 Spark 的常用文档链接 Apache Spark Github https://github.com/apache/spark Apache ...

  7. K8S-网络模型、POD/RC/SVC YAML 语法官方文档

    2019独角兽企业重金招聘Python工程师标准>>> K8S-网络模型.POD/RC/SVC YAML 语法官方文档 博客分类: Kubernetes K8S-网络模型.POD/R ...

  8. 《maven官方文档》5分钟开始Maven

    原文地址 前提 你必须明白如何在电脑上安装软件.如果你不知道如何做,请向你学校.办公室里等的人请教下,或者付费给他人让他们解释给你.Maven邮件组不是寻求这个建议的最好地方. 安装 Maven是个J ...

  9. 《Spring Cloud Netflix官方文档》2. 服务发现:Eureka服务器

    2. 服务发现:Eureka服务器 2.1 如何创建Eureka服务器 引用org.springframework.cloud的spring-cloud-starter-eureka-server就可 ...

最新文章

  1. 打好网约车“安全牌”,T3出行以人、车、路保障
  2. html复选框怎么转成数组,在HTML中将html表转换为数组
  3. vue绑定自定义属性(属性值:false),DOM不显示问题
  4. ListView控件获取选中项的内容 c# 114867417
  5. js将数组中一个或多个字段相同的子元素中合并
  6. IT人母亲的美国之行(8)
  7. 计算机的组策略配置在什么时候生效,修改组策略生效时间
  8. 微信开发获取签名wx.config
  9. IDEA终端光标太粗怎么设置?及操作技巧
  10. 胆囊结石的危害你了解多少?
  11. 金仓数据库KingbaseES本地化支持(4. 排序规则)
  12. 用python做一个简单的游戏,用python写一个小游戏
  13. 2块盘的raid0坏了一块,数据如何恢复?
  14. 连接数据库报Java::ComMysqlCjJdbcExceptions::CommunicationsException: Communications link failure
  15. 软件开发模型之装修篇
  16. 设置服务器网站主页,服务器设置网站主页
  17. 751. 数组的左方区域
  18. Bundle 究竟是什么?
  19. android 地图显示物流,离线地图
  20. DoIP, uds等

热门文章

  1. [置顶]Blender 三维绘图及渲染软件 (开源优秀强大跨平台)
  2. 微信小程序3天刷量开流量主方法
  3. 秒针系统网络广告交易平台介绍
  4. Java Android常用术语英文简称及释义
  5. linux(ubuntu)下照片.jpg和.png相互转换
  6. 【克罗地亚VS巴西】和【荷兰VS阿根廷】足球的魅力
  7. MyBioSource 重组人白细胞介素-24解决方案
  8. 直线回归和相关------(五)直线回归与相关的内在关系和应用要点(回归系数相关系数关系推导)
  9. 服务器维护委托合同,服务器维护委托合同
  10. React入门学习小案例之番茄计时器与温度控制 App