endpoint

将外部服务映射为集群内布,便于配置应用路由等

  1. 创建endpoint对象

  2. addresses: 数组类型,可以为多个,也可以为一个

  3. namespace: 命名空间
cat <<EOF | kubectl apply -f -
kind: Endpoints
apiVersion: v1
metadata: 
  name: mysql-external
  namespace: default
subsets:
- addresses:
  - ip: xxx.xxx.xx.xxx
  ports:
   - port: 3306
     name: mysql-external
EOF
  1. 创建service对象

  2. port: 与endpoint一致

  3. metadata.name: 与endpoint一致
  4. metadata.namespace: 与endpoint一致
cat <<EOF | kubectl apply -f -
kind: Service
apiVersion: v1
metadata:
  name: mysql-external
  namespace: default
spec:
  ports:
  - port: 3306
    name: mysql-external
    targetPort: 3306
EOF
Copyright © weiliang 2021 all right reserved,powered by Gitbook本书发布时间: 2024-04-22 16:03:41

results matching ""

    No results matching ""