码迷,mamicode.com
首页 > 其他好文 > 详细

k8s service

时间:2021-05-24 06:53:19      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:ocs   ice   busybox   replica   dev   cep   exp   back   nec   

 

 

创建 ClusterIP 类型的 Service

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  selector:
    matchLabels:
      app: metrics
      department: sales
  replicas: 3
  template:
    metadata:
      labels:
        app: metrics
        department: sales
    spec:
      containers:
      - name: hello
        image: "gcr.io/google-samples/hello-app:2.0"

将此清单复制到名为 my-deployment.yaml 的文件,然后创建该 Deployment:

 

kubectl apply -f my-deployment.yaml

 

root@ubuntu:~/k8s_server# mv nsexec.c  my-deployment.yaml
root@ubuntu:~/k8s_server# kubectl apply -f my-deployment.yaml
deployment.apps/my-deployment created
root@ubuntu:~/k8s_server# kubectl get pods
NAME                             READY   STATUS              RESTARTS   AGE
kata-busybox                     1/1     Running             0          207d
kata-nginx                       1/1     Running             0          205d
my-deployment-68bdbbb5cc-2d2k6   0/1     ContainerCreating   0          7s
my-deployment-68bdbbb5cc-7fkwp   0/1     ContainerCreating   0          7s
my-deployment-68bdbbb5cc-lk5vr   0/1     ContainerCreating   0          7s
root@ubuntu:~/k8s_server# 

 

技术图片

 

 

 

root@ubuntu:~/k8s_server# kubectl get pods
NAME                             READY   STATUS             RESTARTS   AGE
kata-busybox                     1/1     Running            0          207d
kata-nginx                       1/1     Running            0          205d
my-deployment-68bdbbb5cc-2d2k6   0/1     ImagePullBackOff   0          16m
my-deployment-68bdbbb5cc-7fkwp   0/1     ImagePullBackOff   0          16m
my-deployment-68bdbbb5cc-lk5vr   0/1     ImagePullBackOff   0          16m
root@ubuntu:~/k8s_server# kubectl delete pod my-deployment-68bdbbb5cc-2d2k6  my-deployment-68bdbbb5cc-7fkwp  my-deployment-68bdbbb5cc-lk5vr
pod "my-deployment-68bdbbb5cc-2d2k6" deleted
pod "my-deployment-68bdbbb5cc-7fkwp" deleted
pod "my-deployment-68bdbbb5cc-lk5vr" deleted

 

使用 Service 连接到应用

 

使用 Service 公开应用

 

k8s service

标签:ocs   ice   busybox   replica   dev   cep   exp   back   nec   

原文地址:https://www.cnblogs.com/dream397/p/14759829.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!