2019-11-15 13:41:40 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
var templates = map[string]string{
|
2019-11-21 17:31:13 +00:00
|
|
|
"deployment": deploymentTmpl,
|
|
|
|
"service": serviceTmpl,
|
2020-03-31 12:03:32 +01:00
|
|
|
"namespace": namespaceTmpl,
|
2019-11-15 13:41:40 +00:00
|
|
|
}
|
|
|
|
|
2020-01-18 18:37:38 +00:00
|
|
|
// stripped image pull policy always
|
|
|
|
// imagePullPolicy: Always
|
2019-11-15 13:41:40 +00:00
|
|
|
var deploymentTmpl = `
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
name: "{{ .Metadata.Name }}"
|
|
|
|
namespace: "{{ .Metadata.Namespace }}"
|
|
|
|
labels:
|
|
|
|
{{- with .Metadata.Labels }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2019-11-22 17:10:00 +00:00
|
|
|
annotations:
|
|
|
|
{{- with .Metadata.Annotations }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2019-11-15 13:41:40 +00:00
|
|
|
spec:
|
|
|
|
replicas: {{ .Spec.Replicas }}
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
{{- with .Spec.Selector.MatchLabels }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
{{- with .Spec.Template.Metadata.Labels }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2019-11-26 18:14:49 +00:00
|
|
|
annotations:
|
|
|
|
{{- with .Spec.Template.Metadata.Annotations }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2019-11-15 13:41:40 +00:00
|
|
|
spec:
|
2020-04-23 12:27:36 +01:00
|
|
|
imagePullSecrets:
|
|
|
|
{{- with .Spec.Template.PodSpec.ImagePullSecrets }}
|
|
|
|
{{- range . }}
|
2020-04-23 13:11:00 +01:00
|
|
|
- name: "{{.}}"
|
2020-04-23 12:38:00 +01:00
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2019-11-15 13:41:40 +00:00
|
|
|
containers:
|
|
|
|
{{- with .Spec.Template.PodSpec.Containers }}
|
|
|
|
{{- range . }}
|
|
|
|
- name: {{ .Name }}
|
|
|
|
env:
|
|
|
|
{{- with .Env }}
|
|
|
|
{{- range . }}
|
|
|
|
- name: "{{ .Name }}"
|
|
|
|
value: "{{ .Value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
2020-02-06 12:31:54 +00:00
|
|
|
args:
|
|
|
|
{{- range .Args }}
|
|
|
|
- {{.}}
|
|
|
|
{{- end }}
|
2019-11-15 13:41:40 +00:00
|
|
|
command:
|
|
|
|
{{- range .Command }}
|
|
|
|
- {{.}}
|
|
|
|
{{- end }}
|
|
|
|
image: {{ .Image }}
|
|
|
|
ports:
|
|
|
|
{{- with .Ports }}
|
|
|
|
{{- range . }}
|
|
|
|
- containerPort: {{ .ContainerPort }}
|
|
|
|
name: {{ .Name }}
|
|
|
|
{{- end}}
|
|
|
|
{{- end}}
|
|
|
|
{{- end }}
|
|
|
|
{{- end}}
|
|
|
|
`
|
|
|
|
|
|
|
|
var serviceTmpl = `
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: "{{ .Metadata.Name }}"
|
|
|
|
namespace: "{{ .Metadata.Namespace }}"
|
|
|
|
labels:
|
|
|
|
{{- with .Metadata.Labels }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
{{- with .Spec.Selector }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
ports:
|
|
|
|
{{- with .Spec.Ports }}
|
|
|
|
{{- range . }}
|
|
|
|
- name: "{{ .Name }}"
|
|
|
|
port: {{ .Port }}
|
|
|
|
protocol: {{ .Protocol }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
`
|
2020-03-31 12:03:32 +01:00
|
|
|
|
|
|
|
var namespaceTmpl = `
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Namespace
|
|
|
|
metadata:
|
|
|
|
name: "{{ .Metadata.Name }}"
|
|
|
|
labels:
|
|
|
|
{{- with .Metadata.Labels }}
|
|
|
|
{{- range $key, $value := . }}
|
|
|
|
{{ $key }}: "{{ $value }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
`
|