zoukankan      html  css  js  c++  java
  • k8s 无头service 方式向内发布

    k8s 无头service 是指 clusterIP 为 None 的service

    案例,假定有一个 deployment,containerPort 端口80,同时还被打上 python=myweb 标签。
    deployment内容如下

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: mywebdeployment
    spec:
      selector:
        matchLabels:
          python: myweb
      replicas: 6
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxSurge: 0
          maxUnavailable: 1
      template:
        metadata:
         labels:
           python: myweb
        spec:
          containers:
          - name: mywebcontainer
            image: python:3.7
            command: ['sh', '-c']
            args: ['echo "<p>The host is $(hostname) </p>" > index.html;python -m http.server 80']
            ports:
            - name: mywebport
              containerPort: 80
    

    无头service如下

    apiVersion: v1
    kind: Service
    metadata:
      name: myweb-service
    spec:
      selector:
        python: myweb
      type: ClusterIP
      clusterIP: None
      ports:
      - port: 81
        targetPort: 80
    

    创建工具型pod

    apiVersion: v1
    kind: Pod
    metadata:
      name: mytestpod
      labels:
        pod: test
    spec:
      containers:
      - name: mytestpod
        image: appropriate/curl
        command: ['sh','-c']
        args: ['echo "good";sleep 3600;']
    

    进入工具型Pod,并且在pod中查询service的解析地址 {ServiceName}.{Namespace}.svc.{ClusterDomain}

  • 相关阅读:
    Linux Commands
    sizeof操作符的使用详解
    在Vim中使用cscope
    MySQL学习笔记
    Online judge for leetcode
    使用Vim,让你工作效率更高
    Ext JS笔记
    安装J2EE开发环境
    这些都是什么啊
    QrCode二维码的实现原理
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14156151.html
Copyright © 2011-2022 走看看