我创建了具有以下结构的service helm chart
service/
templates/
service.yaml
values.yaml
Chart.yaml
apiVersion: v1
kind: Service
metadata:
name: {{ required "A valid Application Name is required!" .Values.name }}
namespace: {{ required "A valid namespace is required!" .Values.namespace }}
labels:
{{ range $key, $value := .Values.labels }}
{{ $key }}: {{ $value | quote }}
{{ end }}
annotations:
{{ range $key, $value := .Values.annotations }}
{{ $key }}: {{ $value | quote }}
{{ end }}
spec:
clusterIP: {{ .Values.spec.clusterIP }}
externalIPs: {{ .Values.spec.externalIPs }}
externalName: {{ .Values.spec.externalName }}
externalTrafficPolicy: {{ .Values.spec.externalTrafficPolicy }}
healthCheckNodePort: {{ .Values.spec.healthCheckNodePort }}
loadbalancerIP: {{ .Values.spec.loadbalancerIP }}
loadbalancerSourceRanges:
{{ range .Values.spec.loadbalancerSourceRanges }}
- {{ . | quote }}
{{ end }}
ports:
{{ range .Values.spec.ports }}
- name: {{ .name }}
port: {{ .port }}
protocol: {{ .protocol | quote }}
targetPort: {{ .targetPort }}
{{ end }}
publishNotReadyAddresses: {{ .Values.spec.publishNotReadyAddresses }}
selector:
{{ range $key, $value := .Values.spec.selector }}
{{ $key }}: {{ $value | quote }}
{{ end }}
type: {{ .Values.spec.type }}
name: personal-sandbox-service
namespace: mynamespace
labels:
app: personal-sandbox
annotations:
app: personal-sandbox
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: personal-sandbox
type: ClusterIP
$ helm lint service/
==> Linting service/
[INFO] Chart.yaml: icon is recommended
1 chart(s) linted, 0 chart(s) failed
$ helm version
version.BuildInfo{Version:"v3.2.1", GitCommit:"fe51cd1e31e6a202cba7dead9552a6d418ded79a",
GitTreeState:"clean", GoVersion:"go1.13.10"}
我们正在使用Openshift 4.2
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.6+999bb21", GitCommit:"999bb21", GitTreeState:"clean", BuildDate:"2020-02-17T18:41:39Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
我正在使用Kubernetes 1.14 API Reference Doc确定所有服务属性。
$ helm install test-service service/
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: [apiVersion not set, kind not set]
apiVersion: v1
kind: Service
metadata:
name: personal-sandbox-service
namespace: mynamespace
spec:
type: ClusterIP
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: personal-sandbox
掌舵人,您可以稍后在试用期结束后使用values.yml占位符更新这些值。