当前位置: 首页 > news >正文

个性化网站有哪些百度经验手机版

个性化网站有哪些,百度经验手机版,做公司网站大概多少钱,运营和营销的区别和联系文章目录 Kubernetes进阶一、Namespace(名称空间)1.namespace介绍2.管理namespace查看namespace创建namespaceyaml文件配置namespace 二、Pod(最小基本部署单元)1.pod介绍2.管理pod创建并运行pod查看pod信息访问pod删除podyaml文件…

文章目录

  • Kubernetes进阶
    • 一、Namespace(名称空间)
      • 1.namespace介绍
      • 2.管理namespace
        • 查看namespace
        • 创建namespace
        • yaml文件配置namespace
    • 二、Pod(最小基本部署单元)
      • 1.pod介绍
      • 2.管理pod
        • 创建并运行pod
        • 查看pod信息
        • 访问pod
        • 删除pod
        • yaml文件配置pod
    • 三、Label(标签)
      • 1.label介绍
      • 2.管理label的命令
        • 创建标签(为pod打标签)
        • 查看标签
        • 通过标签筛选
        • 删除标签
        • yaml文件配置lable
    • 四、Deployment(调度器)
      • 1.deployment介绍
      • 2.管理deployment的命令
        • 创建deployment
        • 查看deployment的信息
        • 详细查看deployment的信息
        • 删除deployment
        • 通过yaml文件配置deployment
    • 五、Service
      • 1.service介绍
      • 2.管理service的命令
        • 创建service
          • 一、创建集群内部可访问的Service
          • 二、创建集群外部也可访问的Service
        • 查看service
        • 删除service
        • yaml文件配置service

Kubernetes进阶

一、Namespace(名称空间)

1.namespace介绍

Namespace(名称空间)是kubernetes系统中的一种非常重要资源,它的主要作用是用来实现多套环境的资源隔离或者多租户的资源隔离

默认情况下,kubernetes集群中的所有的Pod都是可以相互访问的。但是在实际中,可能不想让两个Pod之间进行互相的访问,那此时就可以将两个Pod划分到不同的namespace下。kubernetes通过将集群内部的资源分配到不同的Namespace中,可以形成逻辑上的"组",以方便不同的组的资源进行隔离使用和管理。

可以通过kubernetes的授权机制,将不同的namespace交给不同租户进行管理,这样就实现了多租户的资源隔离。此时还能结合kubernetes的资源配额机制,限定不同租户能占用的资源,例如CPU使用量、内存使用量等等,来实现租户可用资源的管理。


在这里插入图片描述

kubernetes在集群启动之后,会默认创建几个namespace

//查看所有的名称空间
[root@master ~]# kubectl get namespace
NAME              STATUS   AGE
default           Active   2d22h	//所有未指定Namespace的对象都会被分配在default命名空间
kube-flannel      Active   2d21h	
kube-node-lease   Active   2d22h	//集群节点之间的心跳维护,v1.13开始引入
kube-public       Active   2d22h	//此命名空间下的资源可以被所有人访问(包括未认证用户)
kube-system       Active   2d22h	//所有由Kubernetes系统创建的资源都处于这个命名空间
[root@master ~]# 

2.管理namespace

查看namespace
//查看所有的namespace
--语法:kubectl get namespace
[root@master ~]# kubectl get namespace
NAME              STATUS   AGE
default           Active   2d22h
kube-flannel      Active   2d21h
kube-node-lease   Active   2d22h
kube-public       Active   2d22h
kube-system       Active   2d22h//查看指定的namespace
--语法:kubectl get namespace namespace名称
[root@master ~]# kubectl get namespace kube-system
NAME          STATUS   AGE
kube-system   Active   2d22h
[root@master ~]# //指定输出格式;kubernetes支持的格式有很多,比较常见的是wide、json、yaml
--语法:kubectl get namespace namespace名称  -o 格式参数
[root@master ~]# kubectl get namespace kube-system -o yaml
apiVersion: v1
kind: Namespace
metadata:creationTimestamp: "2023-11-13T08:40:58Z"labels:kubernetes.io/metadata.name: kube-systemname: kube-systemresourceVersion: "11"uid: 055e9695-d07f-4181-b0e5-32b25919f4ef
spec:finalizers:- kubernetes
status:phase: Active
[root@master ~]# //查看ns详情
--语法:kubectl describe namespace namespace名称
[root@master ~]# kubectl describe namespace kube-system
Name:         kube-system
Labels:       kubernetes.io/metadata.name=kube-system
Annotations:  <none>
Status:       Active	//Active 命名空间正在使用中  Terminating 正在删除命名空间No resource quota.		//ResourceQuota 针对namespace做的资源限制No LimitRange resource.	//LimitRange针对namespace中的每个组件做的资源限制
[root@master ~]# 
创建namespace
//创建一个namespace
--语法:kubectl create namespace namespace名称
[root@master ~]# kubectl create namespace wanf
namespace/wanf created
[root@master ~]# 
yaml文件配置namespace

写一个yaml文件

[root@master ~]# vim ns-lc-yaml
[root@master ~]# cat ns-lc-yaml 
apiVersion: v1
kind: Namespace
metadata:name: lc
[root@master ~]# 

执行对应的创建和删除命令

//创建
[root@master ~]# kubectl create -f ns-lc-yaml 
namespace/lc created
[root@master ~]# //删除
[root@master ~]# kubectl delete -f ns-lc-yaml 
namespace "lc" deleted
[root@master ~]# 


二、Pod(最小基本部署单元)

1.pod介绍

pod是Kubernetes中最小的可调度单位,它可以包含一个或多个容器。Pod代表应用程序的一个实例,包含了共享的网络和存储资源。Pod可以动态地进行伸缩,并且可以在不同的节点之间迁移。

Pod是kubernetes集群进行管理的最小单元,程序要运行必须部署在容器中,而容器必须存在于Pod中。Pod可以认为是容器的封装,一个Pod中可以存在一个或者多个容器。


在这里插入图片描述

kubernetes在集群启动之后,集群中的各个组件也都是以Pod方式运行的。可以通过下面命令查看:

//查看名称空间kube-system里面的pod
[root@master ~]# kubectl get pod -n kube-system
NAME                             READY   STATUS    RESTARTS       AGE
coredns-66f779496c-5thsr         1/1     Running   11 (36m ago)   2d22h
coredns-66f779496c-nqjkx         1/1     Running   11 (36m ago)   2d22h
etcd-master                      1/1     Running   5 (36m ago)    2d22h
kube-apiserver-master            1/1     Running   5 (36m ago)    2d22h
kube-controller-manager-master   1/1     Running   5 (36m ago)    2d22h
kube-proxy-5m7lh                 1/1     Running   5 (36m ago)    2d22h
kube-proxy-7dc82                 1/1     Running   5 (36m ago)    2d22h
kube-proxy-t6fc7                 1/1     Running   5 (36m ago)    2d22h
kube-scheduler-master            1/1     Running   5 (36m ago)    2d22h
[root@master ~]# 

2.管理pod

创建并运行pod

kubernetes没有提供单独运行Pod的命令,都是通过Pod控制器来实现的

# 命令格式: kubectl run (pod控制器名称) [参数] 
# --image  指定Pod的镜像
# --port   指定端口
# --namespace  指定namespace//示例
[root@master ~]# kubectl run httpd --image=lcwanf/apache:v0.2 --port=80 --namespace wanf
pod/httpd created	//创建成功
[root@master ~]# 
查看pod信息
//查看刚刚创建的pod
--查看基本信息
[root@master ~]# kubectl get pods -n wanf 
NAME    READY   STATUS    RESTARTS   AGE
httpd   1/1     Running   0          15m
[root@master ~]# --查看详细信息
[root@master ~]# kubectl describe pod httpd -n wanf
Name:             httpd
Namespace:        wanf
Priority:         0
Service Account:  default
Node:             node2/192.168.179.15
Start Time:       Thu, 16 Nov 2023 15:30:14 +0800
Labels:           run=httpd
Annotations:      <none>
Status:           Running
IP:               10.244.2.8
IPs:IP:  10.244.2.8
Containers:httpd:Container ID:   containerd://301ea62c59afcc16bb8a9ff4b14bbddd4168677c6434acc6bb20d4970d149035Image:          lcwanf/apache:v0.2Image ID:       docker.io/lcwanf/apache@sha256:03b968f7958f5e47650bc785c3bf3a7646fdade94d1e5db589f6aa4bf470d29aPort:           80/TCPHost Port:      0/TCPState:          RunningStarted:      Thu, 16 Nov 2023 15:30:55 +0800Ready:          TrueRestart Count:  0Environment:    <none>Mounts:/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-mk4w7 (ro)
Conditions:Type              StatusInitialized       True Ready             True ContainersReady   True PodScheduled      True 
Volumes:kube-api-access-mk4w7:Type:                    Projected (a volume that contains injected data from multiple sources)TokenExpirationSeconds:  3607ConfigMapName:           kube-root-ca.crtConfigMapOptional:       <nil>DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300snode.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:Type    Reason     Age   From               Message----    ------     ----  ----               -------Normal  Scheduled  17m   default-scheduler  Successfully assigned wanf/httpd to node2Normal  Pulling    17m   kubelet            Pulling image "lcwanf/apache:v0.2"Normal  Pulled     16m   kubelet            Successfully pulled image "lcwanf/apache:v0.2" in 40.558s (40.558s including waiting)Normal  Created    16m   kubelet            Created container httpdNormal  Started    16m   kubelet            Started container httpd
[root@master ~]# 
访问pod
//获取pod的IP地址
[root@master ~]# kubectl get pods -n wanf -o wide
NAME    READY   STATUS    RESTARTS   AGE   IP           NODE    NOMINATED NODE   READINESS GATES
httpd   1/1     Running   0          18m   10.244.2.8   node2   <none>           <none>
[root@master ~]# //使用curl命令访问
[root@master ~]# curl http://10.244.2.8 
<html><body><h1>nice bike</h1></body></html>		//成功访问
[root@master ~]# 
删除pod
//删除指定的pod
[root@master ~]# kubectl delete pod httpd -n wanf
pod "httpd" deleted
[root@master ~]# 
--查看名称空间wanf里面的pod;已经查询不到任何pod,因为这个pod是手动创建的,不是通过deployment创建的,所以不会重新启动一个新的pod。
[root@master ~]# kubectl get pods -n wanf -o wide
No resources found in wanf namespace.
[root@master ~]# 
yaml文件配置pod

写一个yaml文件

[root@master ~]# vim pod-test-yaml
[root@master ~]# cat pod-test-yaml 
apiVersion: v1
kind: Pod
metadata:name: httpdnamespace: wanf
spec:containers:- image: lcwanf/apache:v0.2name: podports:- name: httpd-testcontainerPort: 80protocol: TCP
[root@master ~]# 

执行对应的创建和删除命令

//创建
[root@master ~]# kubectl create -f pod-test-yaml 
pod/httpd created
[root@master ~]# 
--查看创建的pod
[root@master ~]# kubectl get -f pod-test-yaml 
NAME    READY   STATUS    RESTARTS   AGE
httpd   1/1     Running   0          71s
[root@master ~]# //删除
[root@master ~]# kubectl delete -f pod-test-yaml 
pod "httpd" deleted
[root@master ~]# 


三、Label(标签)

1.label介绍

Label是kubernetes系统中的一个重要概念。它的作用就是在资源上添加标识,用来对它们进行区分和选择。

Label的特点:

  • 一个Label会以key/value键值对的形式附加到各种对象上,如Node、Pod、Service等等
  • 一个资源对象可以定义任意数量的Label ,同一个Label也可以被添加到任意数量的资源对象上去
  • Label通常在资源对象定义时确定,当然也可以在对象创建后动态添加或者删除

可以通过Label实现资源的多维度分组,以便灵活、方便地进行资源分配、调度、配置、部署等管理工作。

一些常用的Label 示例如下:

  • 版本标签:“version”:“release”, “version”:“stable”…
  • 环境标签:“environment”:“dev”,“environment”:“test”,“environment”:“pro”
  • 架构标签:“tier”:“frontend”,“tier”:“backend”

标签定义完毕之后,还要考虑到标签的选择,这就要使用到Label Selector,即:

Label用于给某个资源对象定义标识

Label Selector用于查询和筛选拥有某些标签的资源对象

当前有两种Label Selector:

  • 基于等式的Label Selector

    name = slave: 选择所有包含Label中key="name"且value="slave"的对象

    env != production: 选择所有包括Label中的key="env"且value不等于"production"的对象

  • 基于集合的Label Selector

    name in (master, slave): 选择所有包含Label中的key="name"且value="master"或"slave"的对象

    name not in (frontend): 选择所有包含Label中的key="name"且value不等于"frontend"的对象

标签的选择条件可以使用多个,此时将多个Label Selector进行组合,使用逗号","进行分隔即可。例如:

name=slave,env!=production

name not in (frontend),env!=production


2.管理label的命令

创建标签(为pod打标签)
//打单个标签
[root@master ~]# kubectl label pod httpd version=0.2 -n wanf
pod/httpd labeled
[root@master ~]# //打多个标签,用空格隔开
[root@master ~]# kubectl label pod httpd version=0.2 app=httpd master=wanf -n wanf
pod/httpd labeled
[root@master ~]# 
查看标签
//语法:kubectl get pod pod名称 -n 名称空间 --show-labels
[root@master ~]# kubectl get pod httpd -n wanf --show-labels
NAME    READY   STATUS    RESTARTS   AGE     LABELS
httpd   1/1     Running   0          7m43s   app=httpd,master=wanf,version=0.2
[root@master ~]# 
通过标签筛选
//筛选标签app=httpd的pod
[root@master ~]# kubectl get pods -n wanf -l app=httpd --show-labels
NAME    READY   STATUS    RESTARTS   AGE   LABELS
httpd   1/1     Running   0          34m   app=httpd,master=wanf,version=0.2
[root@master ~]# 
//反选,加感叹号!
[root@master ~]# kubectl get pods -n wanf -l app!=httpd --show-labels
No resources found in wanf namespace.
[root@master ~]# 
删除标签
//删除pod里面master=wanf这个标签
[root@master ~]# kubectl label pod httpd master- -n wanf
pod/httpd unlabeled
[root@master ~]# 
--查看删除一个标签后的pod
[root@master ~]# kubectl get pod httpd -n wanf --show-labels
NAME    READY   STATUS    RESTARTS   AGE   LABELS
httpd   1/1     Running   0          37m   app=httpd,version=0.2
[root@master ~]# 
yaml文件配置lable

写一个yaml文件

[root@master ~]# vim lable-pod.yaml 
[root@master ~]# cat lable-pod.yaml 
apiVersion: v1
kind: Pod
metadata:name: httpdv1namespace: wanflabels:version: "0.3" env: "test"
spec:containers:- image: lcwanf/apache:v0.2name: httpd-testports:- name: httpdcontainerPort: 80protocol: TCP
[root@master ~]# 

执行对应的创建和删除命令

//创建
[root@master ~]# kubectl create -f lable-pod.yaml 
pod/httpdv1 created
[root@master ~]# 
--查看创建的pod,并显示标签
[root@master ~]# kubectl get pod -n wanf --show-labels
NAME      READY   STATUS    RESTARTS   AGE   LABELS
httpdv1   1/1     Running   0          71s   env=test,version=0.3
[root@master ~]# //删除
[root@master ~]# kubectl delete -f lable-pod.yaml 
pod "httpdv1" deleted
[root@master ~]# 


四、Deployment(调度器)

1.deployment介绍

在kubernetes中,Pod是最小的控制单元,但是kubernetes很少直接控制Pod,一般都是通过Pod控制器来完成的。Pod控制器用于pod的管理,确保pod资源符合预期的状态,当pod的资源出现故障时,会尝试进行重启或重建pod。

在kubernetes中Pod控制器的种类有很多,本文章只介绍一种:Deployment。

Deployment:用于定义和管理应用程序的部署。Deployment描述了应用程序的期望状态,并负责在集群中创建和更新Pod。它支持滚动更新、回滚和扩缩容等操作。

在这里插入图片描述


2.管理deployment的命令

创建deployment
# 命令格式: kubectl create deployment 名称  [参数] 
# --image  指定pod的镜像
# --port   指定端口
# --replicas  指定创建pod数量
# --namespace  指定namespace//示例
--在名称空间wanf下创建一个名为httpd的deployment,镜像为lcwanf/apache:v0.2,pod数量为4个
[root@master ~]# kubectl create deployment httpd --image=lcwanf/apache:v0.2 --port=80 --replicas=4 -n wanf
deployment.apps/httpd created
[root@master ~]# --查看deployment创建的pod
[root@master ~]# kubectl get pods -n wanf
NAME                    READY   STATUS    RESTARTS   AGE
httpd-cd9dc9fb8-48v28   1/1     Running   0          2m8s
httpd-cd9dc9fb8-dx674   1/1     Running   0          2m8s
httpd-cd9dc9fb8-skkcx   1/1     Running   0          2m8s
httpd-cd9dc9fb8-t59g6   1/1     Running   0          2m8s
[root@master ~]# //删除由deployment创建的pod,deployment会自动重新启动一个新的pod,保证数量满足定义的标准
[root@master ~]# kubectl delete pod httpd-cd9dc9fb8-t59g6 -n wanf
pod "httpd-cd9dc9fb8-t59g6" deleted--依然是四4个pod
[root@master ~]# kubectl get pods -n wanf
NAME                    READY   STATUS    RESTARTS   AGE
httpd-cd9dc9fb8-48v28   1/1     Running   0          4m27s
httpd-cd9dc9fb8-b5wg8   1/1     Running   0          4s
httpd-cd9dc9fb8-dx674   1/1     Running   0          4m27s
httpd-cd9dc9fb8-skkcx   1/1     Running   0          4m27s
[root@master ~]# 
查看deployment的信息
//简单查看
[root@master ~]# kubectl get deployment -n wanf
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
httpd   4/4     4            4           2m50s
[root@master ~]# //较详细查看
# UP-TO-DATE:成功升级的副本数量
# AVAILABLE:可用副本的数量
[root@master ~]# kubectl get deployment -n wanf -o wide
NAME    READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES               SELECTOR
httpd   4/4     4            4           5m43s   apache       lcwanf/apache:v0.2   app=httpd
[root@master ~]# 
详细查看deployment的信息
[root@master ~]# kubectl describe deployment -n wanf
Name:                   httpd
Namespace:              wanf
CreationTimestamp:      Thu, 16 Nov 2023 17:00:46 +0800
Labels:                 app=httpd
Annotations:            deployment.kubernetes.io/revision: 1
Selector:               app=httpd
Replicas:               4 desired | 4 updated | 4 total | 4 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:Labels:  app=httpdContainers:apache:Image:        lcwanf/apache:v0.2Port:         80/TCPHost Port:    0/TCPEnvironment:  <none>Mounts:       <none>Volumes:        <none>
Conditions:Type           Status  Reason----           ------  ------Available      True    MinimumReplicasAvailableProgressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   httpd-cd9dc9fb8 (4/4 replicas created)
Events:Type    Reason             Age    From                   Message----    ------             ----   ----                   -------Normal  ScalingReplicaSet  7m29s  deployment-controller  Scaled up replica set httpd-cd9dc9fb8 to 4
[root@master ~]# 
删除deployment
//删除deployment后才会彻底删除其管理的pod
[root@master ~]# kubectl delete deployment httpd -n wanf
deployment.apps "httpd" deleted
[root@master ~]# 
--查看pod,已经没有任何pod,也不会自动重新启动新的pod
[root@master ~]# kubectl get pods -n wanf
No resources found in wanf namespace.
[root@master ~]# 
通过yaml文件配置deployment

写一个yaml文件

[root@master ~]# vim deployment-httpd.yaml
[root@master ~]# cat deployment-httpd.yaml 
apiVersion: apps/v1
kind: Deployment
metadata:name: httpdnamespace: wanf
spec:replicas: 5selector:matchLabels:run: httpdtemplate:metadata:labels:run: "httpd"version: "0.2"spec:containers:- image: lcwanf/apache:v0.2name: httpd-testports:- containerPort: 80protocol: TCP
[root@master ~]# 

执行对应的创建和删除命令

//创建
[root@master ~]# kubectl create -f deployment-httpd.yaml 
deployment.apps/httpd created
[root@master ~]# 
--查看创建的deployment
[root@master ~]# kubectl get -f deployment-httpd.yaml 
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
httpd   5/5     5            5           71s
--查看该deployment所管理的pod
[root@master ~]# kubectl get pods -n wanf
NAME                     READY   STATUS    RESTARTS   AGE
httpd-56957b6fc7-29k5p   1/1     Running   0          33s
httpd-56957b6fc7-rcrbp   1/1     Running   0          33s
httpd-56957b6fc7-tlqg4   1/1     Running   0          33s
httpd-56957b6fc7-tsx2f   1/1     Running   0          33s
httpd-56957b6fc7-vmhxz   1/1     Running   0          33s
[root@master ~]# //删除
[root@master ~]# kubectl delete -f deployment-httpd.yaml 
deployment.apps "httpd" deleted
[root@master ~]# 


五、Service

1.service介绍

上述方法已经能够利用Deployment来创建一组Pod来提供具有高可用性的服务。

虽然每个Pod都会分配一个单独的Pod IP,然而却存在如下两问题:

  • Pod IP 会随着Pod的重建产生变化
  • Pod IP 仅仅是集群内可见的虚拟IP,外部无法访问

这样对于访问这个服务带来了难度。因此,kubernetes设计了Service来解决这个问题。

Service可以看作是一组同类Pod对外的访问接口。借助Service,应用可以方便地实现服务发现和负载均衡。

在这里插入图片描述


2.管理service的命令

创建service

先创建一个Deployment

[root@master ~]# kubectl create deployment httpd --image=lcwanf/apache:v0.2 --port=80 --replicas=4 -n wanf
deployment.apps/httpd created
一、创建集群内部可访问的Service
//创建type类型为ClusterIP的service并暴露
[root@master ~]# kubectl expose deployment httpd --name=svc-httpd1 --type=ClusterIP --port=80 --target-port=80 -n wanf
service/svc-httpd1 exposed
[root@master ~]# //查看service
# 这里产生了一个CLUSTER-IP,这就是service的IP,在Service的生命周期中,这个地址是不会变动的
[root@master ~]# kubectl get svc svc-httpd1 -n wanf -o wide
NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE   SELECTOR
svc-httpd1   ClusterIP   10.101.14.185   <none>        80/TCP    51s   app=httpd
[root@master ~]# //在内部使用service的IP访问
[root@master ~]# curl 10.101.14.185
<html><body><h1>nice bike</h1></body></html>
[root@master ~]# 
二、创建集群外部也可访问的Service
# 上面创建的Service的type类型为ClusterIP,这个ip地址只用集群内部可访问
# 如果需要创建外部也可以访问的Service,需要修改type为NodePort//创建一个新的service,修改service的type类型为NodePort 
[root@master ~]# kubectl expose deployment httpd --name=svc-httpd2 --type=NodePort  --port=80 --target-port=80 -n wanf
service/svc-httpd2 exposed
[root@master ~]# //查看这个service
##会发现出现了NodePort类型的Service,而且有一对Port(80:31754/TCP)
[root@master ~]# kubectl get svc svc-httpd2 -n wanf -o wide
NAME         TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE   SELECTOR
svc-httpd2   NodePort   10.103.63.181   <none>        80:31754/TCP   99s   app=httpd
[root@master ~]# 

在浏览器访问,成功访问

在这里插入图片描述


查看service
//查看某个名称空间里面的所有service
[root@master ~]# kubectl get svc -n wanf
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
svc-httpd1   ClusterIP   10.101.249.235   <none>        80/TCP         2s
svc-httpd2   NodePort    10.101.168.65    <none>        80:30189/TCP   8s
[root@master ~]# //查看某一个service
[root@master ~]# kubectl get svc svc-httpd1 -n wanf
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
svc-httpd1   ClusterIP   10.101.249.235   <none>        80/TCP    28s
[root@master ~]# 
删除service
//删除service1
[root@master ~]# kubectl delete svc svc-httpd1 -n wanf
service "svc-httpd1" deleted//删除service2
[root@master ~]# kubectl delete svc svc-httpd2 -n wanf
service "svc-httpd2" deleted
[root@master ~]# //查看名称空间wanf里面的service,已经没有任何service
[root@master ~]# kubectl get svc -n wanf
No resources found in wanf namespace.
[root@master ~]# 
yaml文件配置service

写一个yaml文件

[root@master ~]# vim svc-httpd-yaml
[root@master ~]# cat svc-httpd-yaml 
apiVersion: v1
kind: Service
metadata:name: svc-httpdnamespace: wanf
spec:clusterIP: 10.101.249.111	#固定svc的内网ipports:- port: 80protocol: TCPtargetPort: 80selector:run: httpdtype: ClusterIP
[root@master ~]# 

执行对应的创建和删除命令

//创建
[root@master ~]# kubectl create -f svc-httpd-yaml 
service/svc-httpd created
[root@master ~]# 
--查看创建的service
[root@master ~]# kubectl get -f svc-httpd-yaml 
NAME        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE
svc-httpd   ClusterIP   10.101.249.111   <none>        80/TCP    18s
[root@master ~]# //删除service
[root@master ~]# kubectl delete -f svc-httpd-yaml 
service "svc-httpd" deleted
[root@master ~]# 



文章转载自:
http://postmedial.sqLh.cn
http://overstrict.sqLh.cn
http://hematocyst.sqLh.cn
http://necrotize.sqLh.cn
http://superradiant.sqLh.cn
http://formally.sqLh.cn
http://unskillful.sqLh.cn
http://citrinin.sqLh.cn
http://gill.sqLh.cn
http://horsemeat.sqLh.cn
http://horrified.sqLh.cn
http://taphole.sqLh.cn
http://petiolate.sqLh.cn
http://ngbandi.sqLh.cn
http://poetically.sqLh.cn
http://interclavicle.sqLh.cn
http://yarraman.sqLh.cn
http://semioccasional.sqLh.cn
http://privateer.sqLh.cn
http://scythia.sqLh.cn
http://unification.sqLh.cn
http://knur.sqLh.cn
http://usbek.sqLh.cn
http://insufflation.sqLh.cn
http://bigger.sqLh.cn
http://habitability.sqLh.cn
http://impulse.sqLh.cn
http://torpefy.sqLh.cn
http://guinzo.sqLh.cn
http://iphigenia.sqLh.cn
http://unappreciated.sqLh.cn
http://proclivity.sqLh.cn
http://imam.sqLh.cn
http://reovirus.sqLh.cn
http://strobil.sqLh.cn
http://verna.sqLh.cn
http://calvarian.sqLh.cn
http://brutism.sqLh.cn
http://kenyan.sqLh.cn
http://morphallaxis.sqLh.cn
http://batting.sqLh.cn
http://homalographic.sqLh.cn
http://strongbox.sqLh.cn
http://disulfoton.sqLh.cn
http://dulcinea.sqLh.cn
http://gurmukhi.sqLh.cn
http://woodhorse.sqLh.cn
http://devolatilize.sqLh.cn
http://buttlegging.sqLh.cn
http://splodgy.sqLh.cn
http://boyishly.sqLh.cn
http://beauty.sqLh.cn
http://macrocosmos.sqLh.cn
http://podsol.sqLh.cn
http://soilborne.sqLh.cn
http://dentition.sqLh.cn
http://manage.sqLh.cn
http://schnaps.sqLh.cn
http://piteously.sqLh.cn
http://scalar.sqLh.cn
http://harmine.sqLh.cn
http://leveling.sqLh.cn
http://admirable.sqLh.cn
http://underload.sqLh.cn
http://aduertiser.sqLh.cn
http://jolley.sqLh.cn
http://salesite.sqLh.cn
http://priory.sqLh.cn
http://multinest.sqLh.cn
http://phosphokinase.sqLh.cn
http://wardrobe.sqLh.cn
http://denationalization.sqLh.cn
http://stp.sqLh.cn
http://arthrodial.sqLh.cn
http://celature.sqLh.cn
http://condign.sqLh.cn
http://bedlamp.sqLh.cn
http://trichloronitromethane.sqLh.cn
http://coarsely.sqLh.cn
http://porkpie.sqLh.cn
http://maracaibo.sqLh.cn
http://colloquize.sqLh.cn
http://spatted.sqLh.cn
http://acerbating.sqLh.cn
http://vernissage.sqLh.cn
http://populate.sqLh.cn
http://stoop.sqLh.cn
http://sinus.sqLh.cn
http://internauts.sqLh.cn
http://umbrella.sqLh.cn
http://extranuclear.sqLh.cn
http://astrology.sqLh.cn
http://barrier.sqLh.cn
http://mandi.sqLh.cn
http://gayal.sqLh.cn
http://deseam.sqLh.cn
http://alvine.sqLh.cn
http://stereograph.sqLh.cn
http://thundrous.sqLh.cn
http://caravansary.sqLh.cn
http://www.15wanjia.com/news/83155.html

相关文章:

  • 房产如何做网站建网站赚钱
  • 餐饮网站建设设计什么叫关键词举例
  • 集团网站网页模板厦门网络关键词排名
  • 大丰做网站建设的公司网站做seo教程
  • 阿里妈妈广告联盟如何做网站主短视频代运营方案策划书
  • 响应式网站宽度谷歌sem
  • 深圳乐创网站建设社区推广
  • led灯外贸网站建设网站推广费用
  • 七星彩投注网站怎么做成都网站建设方案外包
  • 手机网站导航代码交换链接营销
  • 网站设计的七个原则新闻头条最新消息摘抄
  • 网站建设与管理资料下载旅游网站的网页设计
  • 网站中滚动条怎么做可以发广告的平台
  • 帮人做兼职的网站windows优化大师有用吗
  • 松江做网站的公司seo是什么seo怎么做
  • 最好的网站建设多少钱做百度推广的业务员电话
  • 电商网站的数据库设计如何免费开自己的网站
  • 做价值投资有哪些网站深圳龙岗区疫情最新消息
  • wordpress做账号登录界面长安网站优化公司
  • 临海做网站的公司做seo排名好的公司
  • 网站地图制作怎么做?免费注册网站有哪些
  • 天长网站seo常州seo招聘
  • 手机网站用户体验seo交互论坛
  • 如何寻找网站建设需求客户广告传媒公司
  • 外贸做网站seo怎么做整站排名
  • 深圳市政府网站官网dw网页设计模板网站
  • 网站标题字体深圳市昊客网络科技有限公司
  • 甘肃省城乡住房建设厅网站站长推广网
  • wordpress 菜价插件seo网站诊断流程
  • 如何做免费网站制作2024年阳性最新症状