| 1 | {{/* |
| 2 | Define ports for the pods |
| 3 | */}} |
| 4 | {{- define "chart.container-port" -}} |
| 5 | {{- default "8000" .Values.containerPort }} |
| 6 | {{- end }} |
| 7 | |
| 8 | {{/* |
| 9 | Define service name |
| 10 | */}} |
| 11 | {{- define "chart.service-name" -}} |
| 12 | {{- if .Values.serviceName }} |
| 13 | {{- .Values.serviceName | lower | trim }} |
| 14 | {{- else }} |
| 15 | {{- printf "%s-service" .Release.Name }} |
| 16 | {{- end }} |
| 17 | {{- end }} |
| 18 | |
| 19 | {{/* |
| 20 | Define deployment name |
| 21 | */}} |
| 22 | {{- define "chart.deployment-name" -}} |
| 23 | {{- printf "%s-deployment-vllm" .Release.Name }} |
| 24 | {{- end }} |
| 25 | |
| 26 | {{/* |
| 27 | Define service port |
| 28 | */}} |
| 29 | {{- define "chart.service-port" -}} |
| 30 | {{- if .Values.servicePort }} |
| 31 | {{- .Values.servicePort }} |
| 32 | {{- else }} |
| 33 | {{- include "chart.container-port" . }} |
| 34 | {{- end }} |
| 35 | {{- end }} |
| 36 | |
| 37 | {{/* |
| 38 | Define service port name |
| 39 | */}} |
| 40 | {{- define "chart.service-port-name" -}} |
| 41 | "service-port" |
| 42 | {{- end }} |
| 43 | |
| 44 | {{/* |
| 45 | Define container port name |
| 46 | */}} |
| 47 | {{- define "chart.container-port-name" -}} |
| 48 | "container-port" |
| 49 | {{- end }} |
| 50 | |
| 51 | {{/* |
| 52 | Define deployment strategy |
| 53 | */}} |
| 54 | {{- define "chart.strategy" -}} |
| 55 | strategy: |
| 56 | {{- if not .Values.deploymentStrategy }} |
| 57 | rollingUpdate: |
| 58 | maxSurge: 100% |
| 59 | maxUnavailable: 0 |
| 60 | {{- else }} |
| 61 | {{ toYaml .Values.deploymentStrategy | indent 2 }} |
| 62 | {{- end }} |
| 63 | {{- end }} |
| 64 | |
| 65 | {{/* |
| 66 | Define additional ports |
| 67 | */}} |
| 68 | {{- define "chart.extraPorts" }} |
| 69 | {{- with .Values.extraPorts }} |
| 70 | {{ toYaml . }} |
| 71 | {{- end }} |
| 72 | {{- end }} |
| 73 | |
| 74 | {{/* |
| 75 | Define chart external ConfigMaps and Secrets |
| 76 | */}} |
| 77 | {{- define "chart.externalConfigs" -}} |
| 78 | {{- with .Values.externalConfigs -}} |
| 79 | {{ toYaml . }} |
| 80 | {{- end }} |
| 81 | {{- end }} |
| 82 | |
| 83 | |
| 84 | {{/* |
| 85 | Define liveness et readiness probes |
| 86 | */}} |
| 87 | {{- define "chart.probes" -}} |
| 88 | {{- if .Values.readinessProbe }} |
| 89 | readinessProbe: |
| 90 | {{- with .Values.readinessProbe }} |
| 91 | {{- toYaml . | nindent 2 }} |
| 92 | {{- end }} |
| 93 | {{- end }} |
| 94 | {{- if .Values.livenessProbe }} |
| 95 | livenessProbe: |
| 96 | {{- with .Values.livenessProbe }} |
| 97 | {{- toYaml . | nindent 2 }} |
| 98 | {{- end }} |
| 99 | {{- end }} |
| 100 | {{- end }} |
| 101 | |
| 102 | {{/* |
| 103 | Define resources |
| 104 | */}} |
| 105 | {{- define "chart.resources" -}} |
| 106 | requests: |
| 107 | memory: {{ required "Value 'resources.requests.memory' must be defined !" .Values.resources.requests.memory | quote }} |
| 108 | cpu: {{ required "Value 'resources.requests.cpu' must be defined !" .Values.resources.requests.cpu | quote }} |
| 109 | {{- if and (gt (int (index .Values.resources.requests "nvidia.com/gpu")) 0) (gt (int (index .Values.resources.limits "nvidia.com/gpu")) 0) }} |
| 110 | nvidia.com/gpu: {{ required "Value 'resources.requests.nvidia.com/gpu' must be defined !" (index .Values.resources.requests "nvidia.com/gpu") | quote }} |
| 111 | {{- end }} |
| 112 | limits: |
| 113 | memory: {{ required "Value 'resources.limits.memory' must be defined !" .Values.resources.limits.memory | quote }} |
| 114 | cpu: {{ required "Value 'resources.limits.cpu' must be defined !" .Values.resources.limits.cpu | quote }} |
| 115 | {{- if and (gt (int (index .Values.resources.requests "nvidia.com/gpu")) 0) (gt (int (index .Values.resources.limits "nvidia.com/gpu")) 0) }} |
| 116 | nvidia.com/gpu: {{ required "Value 'resources.limits.nvidia.com/gpu' must be defined !" (index .Values.resources.limits "nvidia.com/gpu") | quote }} |
| 117 | {{- end }} |
| 118 | {{- end }} |
| 119 | |
| 120 | |
| 121 | {{/* |
| 122 | Define User used for the main container |
| 123 | */}} |
| 124 | {{- define "chart.user" }} |
| 125 | {{- if .Values.image.runAsUser }} |
| 126 | runAsUser: |
| 127 | {{- with .Values.runAsUser }} |
| 128 | {{- toYaml . | nindent 2 }} |
| 129 | {{- end }} |
| 130 | {{- end }} |
| 131 | {{- end }} |
| 132 | |
| 133 | |
| 134 | {{- define "chart.extraInitEnv" -}} |
| 135 | - name: S3_ENDPOINT_URL |
| 136 | valueFrom: |
| 137 | secretKeyRef: |
| 138 | name: {{ .Release.Name }}-secrets |
| 139 | key: s3endpoint |
| 140 | - name: S3_BUCKET_NAME |
| 141 | valueFrom: |
| 142 | secretKeyRef: |
| 143 | name: {{ .Release.Name }}-secrets |
| 144 | key: s3bucketname |
| 145 | - name: AWS_ACCESS_KEY_ID |
| 146 | valueFrom: |
| 147 | secretKeyRef: |
| 148 | name: {{ .Release.Name }}-secrets |
| 149 | key: s3accesskeyid |
| 150 | - name: AWS_SECRET_ACCESS_KEY |
| 151 | valueFrom: |
| 152 | secretKeyRef: |
| 153 | name: {{ .Release.Name }}-secrets |
| 154 | key: s3accesskey |
| 155 | {{- if .Values.extraInit.s3modelpath }} |
| 156 | - name: S3_PATH |
| 157 | value: "{{ .Values.extraInit.s3modelpath }}" |
| 158 | {{- end }} |
| 159 | {{- if hasKey .Values.extraInit "awsEc2MetadataDisabled" }} |
| 160 | - name: AWS_EC2_METADATA_DISABLED |
| 161 | value: "{{ .Values.extraInit.awsEc2MetadataDisabled }}" |
| 162 | {{- end }} |
| 163 | {{- end }} |
| 164 | |
| 165 | {{/* |
| 166 | Define chart labels |
| 167 | */}} |
| 168 | {{- define "chart.labels" -}} |
| 169 | {{- with .Values.labels -}} |
| 170 | {{ toYaml . }} |
| 171 | {{- end }} |
| 172 | {{- end }} |