Skip to content

Latest commit

 

History

History
46 lines (38 loc) · 783 Bytes

endpoint.md

File metadata and controls

46 lines (38 loc) · 783 Bytes

endpoint

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

  1. 创建endpoint对象
  • addresses: 数组类型,可以为多个,也可以为一个
  • 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对象
  • port: 与endpoint一致
  • metadata.name: 与endpoint一致
  • 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