配置BCI Pod访问集群内Service
更新时间:2024-09-25
概述
BCI支持从BCI实例中访问K8S ClusterIP类型Service。如果您需要在BCI实例中访问集群中ClusterIP, 您需要在Pod Spec Yaml中添加如下Annotation,用于开启功能:
bci.virtual-kubelet.io/kube-proxy-enabled: true
Annotation 请添加在Pod的metadata下,例如:创建Deployment时,Annotation需添加在spec>template>metadata下。 仅支持在创建BCI Pod时添加BCI相关Annotation来生效BCI功能,已成功的BCI Pod只能重建来生效。
配置示例
以创建一个简单的Nginx为例,Nginx的Pod 会调度到VNode上:
kind: Service
apiVersion: v1
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- name: nginx-port
port: 80
targetPort: 80
protocol: TCP
---
apiVersion: v1
kind: Pod
metadata:
name: nginx-bci
labels:
app: nginx
annotations:
"bci.virtual-kubelet.io/kube-proxy-enabled": "true" #添加这个annotation
spec:
nodeSelector:
type: "virtual-kubelet"
tolerations:
- key: "virtual-kubelet.io/provider"
operator: "Equal"
value: "baidu"
effect: "NoSchedule"
containers:
- name: sun-nginx-host
imagePullPolicy: IfNotPresent
image: hub.baidubce.com/jpaas-public/nginx-alpine-go:latest
resources:
limits:
cpu: 0.5
memory: 1Gi
requests:
cpu: 0.5
memory: 1Gi