美文网首页
deployment+service.yaml

deployment+service.yaml

作者: 阿汤哥_8d27 | 来源:发表于2021-11-04 19:19 被阅读0次

    deployment.yaml

    使用hostAliases将hosts解析写入pod中的/etc/hosts

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        k8s-app: tomcat8
      name: tomcat8
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          k8s-app: tomcat8
      strategy:
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 0
        type: RollingUpdate
      template:
        metadata:
          labels:
            k8s-app: tomcat8
        spec:
          containers:
          - image: ccr.ccs.tencentyun.com/ecool_tomcat8/centos7-jdk1.8-tomcat8:v3
            imagePullPolicy: IfNotPresent
            name: tomcat8
            resources:
              limits:
                cpu: 500m
                memory: 1Gi
              requests:
                cpu: 250m
                memory: 256Mi
          dnsPolicy: ClusterFirst
          restartPolicy: Always
          hostAliases:
          - hostnames:
            - logdb1
            ip: 172.17.0.
          - hostnames:
            - confcdb1
            ip: 172.17.0.
    

    service.yaml

    service通过NodePort方式访问endpoints

    apiVersion: v1
    kind: Service
    metadata:
      name: tomcat8
      namespace: default
    spec:
      ports:
      - name: 8080-8080-tcp
        nodePort: 30000
        port: 8080
        protocol: TCP
        targetPort: 8080
      selector:
        k8s-app: tomcat8
      sessionAffinity: None
      type: NodePort
    

    相关文章

      网友评论

          本文标题:deployment+service.yaml

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