资源配置YML运行kubernetes的相关容器(二)

集成环境部署

/usr/local/kubernetes/yaml内,创建nginx.yml,内容如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-app
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 2
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
 
# 特别注意下面的三条横杠 
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-http
spec:
  ports:
    - port: 80
      targetPort: 80
      nodePort: 80
  type: LoadBalancer
  selector:
    app: nginx
  • kubectl create -f nginx.yml来将其运行
  • kubectl delete -f nginx.yml来停止运行
发布了170 篇原创文章 · 获赞 20 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_41967899/article/details/104069471
今日推荐