文章

helm-chat文件编排

获取SVC_IP 或者 EXTERNAL_IP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
 {{- define "apollo.configService.service.externalIP" -}} 
 {{- $svcName := include "apollo.configService.serviceName" . -}} 
 {{- printf "svcName: %s\n" $svcName -}} 
 {{- printf "configService.service: %#v\n" .Values.configService.service -}} 
 {{- $ns := .Release.Namespace -}} 
 {{- printf "ns: %s\n" $ns -}} 
 {{- printf "lookup: %v\n" (lookup "v1" "Service" $ns $svcName).status -}} 
 {{- $svc := index (lookup "v1" "Service" $ns $svcName) -}} 
 {{- printf "svc: %#v\n" $svc -}} 
 {{- printf "svc.spec.type: %#s\n" ($svc.spec).type -}} 
 {{- if eq $svc.spec.type "LoadBalancer" -}} 
 {{- index $svc.status.loadBalancer.ingress 0 "ip" -}} 
 {{- with $svcName -}} 
 {{- end -}} 
 {{- end -}} 
 {{- end -}} 


 {{/*  
    引用 
*/}}
env:
  - name: SVC_EXTERNAL_IP
     value: {{ include "apollo.configService.service.externalIP" . }} 

根据服务对应的 标签值不同设置不同值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
values.yaml
gpulabel: NVIDIA-A100-SXM4-80GB

templates/knative-service.yaml 
# 默认Tesla-T4,如果有设置 .Values.gpulabel 中的标签,则为标签值
spec:
      # tolerations
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: aliyun.accelerator/nvidia_name
                operator: In
                values:
                 - {{ default "Tesla-T4" .Values.gpulabel }} 
本文由作者按照 CC BY 4.0 进行授权