templates

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Manifest = NewTemplate("manifest", `
---
apiVersion: v1
kind: Namespace
metadata:
  name: {{.Namespace}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    component: sonobuoy
  name: sonobuoy-serviceaccount
  namespace: {{.Namespace}}
{{- if .EnableRBAC }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    component: sonobuoy
  name: sonobuoy-serviceaccount-{{.Namespace}}
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: sonobuoy-serviceaccount
subjects:
- kind: ServiceAccount
  name: sonobuoy-serviceaccount
  namespace: {{.Namespace}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    component: sonobuoy
  name: sonobuoy-serviceaccount
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '/metrics'
  - '/logs'
  - '/logs/*'
  verbs:
  - 'get'
{{- end }}
{{- if .SSHKey }}
---
apiVersion: v1
kind: Secret
metadata:
  name: ssh-key
  namespace: {{.Namespace}}
type: Opaque
data:
  id_rsa: {{.SSHKey}}
{{- end }}
---
apiVersion: v1
data:
  config.json: |
    {{.SonobuoyConfig}}
kind: ConfigMap
metadata:
  labels:
    component: sonobuoy
  name: sonobuoy-config-cm
  namespace: {{.Namespace}}
---
apiVersion: v1
{{- if .Plugins }}
data:{{- range $i, $v := .Plugins }}
  plugin-{{- $i -}}.yaml: |
    {{ indent 4 $v }}
{{- end }}
{{- end }}
kind: ConfigMap
metadata:
  labels:
    component: sonobuoy
  name: sonobuoy-plugins-cm
  namespace: {{.Namespace}}
---
apiVersion: v1
kind: Pod
metadata:
  labels:
    component: sonobuoy
    run: sonobuoy-master
    tier: analysis
  name: sonobuoy
  namespace: {{.Namespace}}
{{- if .CustomAnnotations }}
  annotations:{{- range $k, $v := .CustomAnnotations }}
    {{ indent 4 $k}}: {{$v}}
{{- end }}
{{- end }}
spec:
  containers:
  - command:
    - /bin/bash
    - -c
    - /sonobuoy master --no-exit=true -v 3 --logtostderr
    env:
    - name: SONOBUOY_ADVERTISE_IP
      valueFrom:
        fieldRef:
          fieldPath: status.podIP
    image: {{.SonobuoyImage}}
    imagePullPolicy: {{.ImagePullPolicy}}
    name: kube-sonobuoy
    volumeMounts:
    - mountPath: /etc/sonobuoy
      name: sonobuoy-config-volume
    - mountPath: /plugins.d
      name: sonobuoy-plugins-volume
    - mountPath: /tmp/sonobuoy
      name: output-volume
  {{- if .ImagePullSecrets }}
  imagePullSecrets:
  - name: {{.ImagePullSecrets}}
  {{- end }}
  restartPolicy: Never
  serviceAccountName: sonobuoy-serviceaccount
  tolerations:
  - key: "kubernetes.io/e2e-evict-taint-key"
    operator: "Exists"
  volumes:
  - configMap:
      name: sonobuoy-config-cm
    name: sonobuoy-config-volume
  - configMap:
      name: sonobuoy-plugins-cm
    name: sonobuoy-plugins-volume
  - emptyDir: {}
    name: output-volume
---
{{- if .CustomRegistries }}
apiVersion: v1
data:
  repo-list.yaml: |
    {{ indent 4 .CustomRegistries }}
kind: ConfigMap
metadata:
  name: repolist-cm
  namespace: {{.Namespace}}
---
{{- end}}
apiVersion: v1
kind: Service
metadata:
  labels:
    component: sonobuoy
    run: sonobuoy-master
  name: sonobuoy-master
  namespace: {{.Namespace}}
spec:
  ports:
  - port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    run: sonobuoy-master
  type: ClusterIP
`)

Manifest is the template found in examples

View Source
var TemplateFuncs = map[string]interface{}{
	"indent": func(i int, input string) string {
		split := strings.Split(input, "\n")
		ident := "\n" + strings.Repeat(" ", i)

		return strings.Join(split, ident)
	},
}

TemplateFuncs exports (currently singular) functions to be used inside the template

Functions

func NewTemplate

func NewTemplate(name, tmpl string) *template.Template

NewTemplate declares a new template that already has TemplateFuncs in scope

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL