加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用yaml配置文件管理资源

发布时间:2020-12-15 20:54:39 所属栏目:安全 来源:网络整理
导读:[[email?protected] ~]# vim nginx-deployment.yaml ? apiVersion: apps/v1beta2 kind: Deployment metadata: ??name: nginx-deployment spec: ??replicas: 3 ??selector: ????matchLabels: ?????app: nginx ??template: ????metadata: ?????labels: ??????a

[[email?protected] ~]# vim nginx-deployment.yaml

?

apiVersion: apps/v1beta2

kind: Deployment

metadata:

??name: nginx-deployment

spec:

??replicas: 3

??selector:

????matchLabels:

?????app: nginx

??template:

????metadata:

?????labels:

??????app: nginx

????spec:

??????containers:

??????- name: nginx

????????image: nginx:1.10

????????ports:

????????- containerPort: 80

[[email?protected] ~]# kubectl create -f nginx-deployment.yaml

[[email?protected] ~]# kubectl get pod

NAME ???????????????????????????????READY ????STATUS ???RESTARTS ??AGE

busybox-5d4f595646-dzjv4 ???????????1/1 ??????Running ??0 ?????????2d

nginx-deployment-58d6d6ccb8-6br4c ??1/1 ??????Running ??0 ?????????1m

nginx-deployment-58d6d6ccb8-6v7m9 ??1/1 ??????Running ??0 ?????????1m

nginx-deployment-58d6d6ccb8-8cp7s ??1/1 ??????Running ??0 ?????????1m

?

[[email?protected] ~]# vim nginx-service.yaml

apiVersion: v1

kind: Service

metadata:

??name: nginx-service

??labels:

????app: nginx

spec:

??ports:

??- port: 88

????targetPort: 80

??selector:

????app: nginx

?

[[email?protected] ~]# kubectl create -f nginx-service.yaml

[[email?protected] ~]# kubectl get svc

NAME ???????????TYPE ???????CLUSTER-IP ???EXTERNAL-IP ??PORT(S) ??AGE

kubernetes ?????ClusterIP ??10.10.10.1 ???<none> ???????443/TCP ??4d

nginx-service ??ClusterIP ??10.10.10.85 ??<none> ???????88/TCP ???40s

[[email?protected] ~]# curl 10.10.10.85:88

<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

?

[[email?protected] ~]# curl 10.10.10.85:88

<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读