美文网首页k8s
k8s 通过配置文件启动nginx服务

k8s 通过配置文件启动nginx服务

作者: 木木111314 | 来源:发表于2021-01-21 15:53 被阅读0次

    1 创建yaml配置文件

    nginx111.yaml

    
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      generation: 6
      labels:
        appname: nginx111
      name: nginx111
      namespace: default 
    spec:
      progressDeadlineSeconds: 600
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          appname: nginx111  
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 0
        type: RollingUpdate
      template:
        metadata:
          labels:
            appname: nginx111         
        spec:
          containers:
          - image: nginx
            imagePullPolicy: IfNotPresent
            name: intellect
            ports:
            - containerPort: 80
    ---
    apiVersion: v1  
    kind: Service  
    metadata:
      name: nginx111-svc  
    spec:
      type: NodePort
      selector:  
        appname: nginx111
      ports:  
      - name: p3000
        protocol: TCP
        port: 80
        targetPort: 80 # pod端口
        nodePort: 31319  # 对外访问端口
    

    把该文件上传至 ks8 master 节点任意目录下。

    2 部署服务

    kubectl apply -f  nginx111.yaml
    

    3 取消部署服务

    kubectl delete -f  nginx111.yaml
    

    相关文章

      网友评论

        本文标题:k8s 通过配置文件启动nginx服务

        本文链接:https://www.haomeiwen.com/subject/mwcdzktx.html