github.com/blend/go-sdk@v1.20220411.3/template/testdata/test.template.yml (about)

     1  {{- $defaultNamespace := "blend" -}}
     2  {{- $defaultServiceEnv := "sandbox" -}}
     3  {{- $defaultCluster := ( .Env "CLUSTER_NAME" "sandbox.blend.com" ) -}}
     4  {{- $defaultRegistry := ( $defaultCluster | prefix "registry." ) -}}
     5  {{- $defaultFQDN := ( .Var "name" | suffix $defaultCluster ) -}}
     6  {{- $defaultAccessibility := "internal" -}}
     7  {{- $defaultReplicas := "2" -}}
     8  {{- $defaultContainerPort := 5000 -}}
     9  
    10  apiVersion: apps/v1beta1
    11  kind: Deployment
    12  metadata:
    13    name: {{ .Var "name" }}
    14    namespace: {{ .Var "namespace" $defaultNamespace }}
    15    labels:
    16      service: {{ .Var "name" }}
    17      env: {{ .Env "SERVICE_ENV" "sandbox" }}
    18  spec:
    19    replicas: {{ .Var "replicas" $defaultReplicas }}
    20    template:
    21      metadata:
    22        labels:
    23          service: {{ .Var "name" }}
    24          env: {{ .Env "SERVICE_ENV" "sandbox"  }}
    25      spec:
    26        containers:
    27        - name: {{ .Var "container-name" ( .Var "name" ) }}
    28          image: {{ .Var "container-image" ( $defaultRegistry | suffix ( .Var "name" ) ) }}
    29          {{- if .HasVar "env" }}
    30          env:
    31          {{- range $index, $var := ( .Var "env" ) }}
    32            - name: {{ $var.name }}
    33              value: {{ $var.value }}
    34          {{- end }}
    35          {{- end -}}
    36          {{- if .Var "container-port" $defaultContainerPort | as_string | ne "disabled" }}
    37          ports:
    38          - containerPort: {{ .Var "container-port" $defaultContainerPort }}
    39          {{- end }}
    40  {{- if .Var "accessibility" $defaultAccessibility | ne "cluster" }}
    41  ---
    42  apiVersion: v1
    43  kind: Service
    44  metadata:
    45    name: {{ .Var "name" }}
    46    namespace: {{ .Var "namepsace" $defaultNamespace }}
    47    labels:
    48      service: {{ .Var "name" }}
    49      env: {{ .Env "SERVICE_ENV" $defaultServiceEnv }}
    50  spec:
    51    selector:
    52      service: {{ .Var "name" }}
    53    type: NodePort
    54    ports:
    55    - name: {{ .Var "name" }}
    56      port: {{ .Var "container-port" $defaultContainerPort }}
    57      protocol: {{ .Var "container-protocol" "tcp" | to_upper }}
    58  {{- end }}
    59  {{- if .Var "accessibility" $defaultAccessibility | eq "external" }}
    60  ---
    61  apiVersion: extensions/v1beta1
    62  kind: Ingress
    63  metadata:
    64    name: {{ .Var "name" }}
    65    namespace: {{ .Var "namespace" $defaultNamespace }}
    66    labels:
    67      service: {{ .Var "name" }}
    68      env: {{ .Env "SERVICE_ENV" $defaultServiceEnv }}
    69  spec:
    70    rules:
    71    - host: {{ .Var "fqdn" $defaultFQDN }}
    72      http:
    73        paths:
    74        - path: /
    75          backend:
    76            serviceName: {{ .Var "name" }}
    77            servicePort: {{ .Var "container-port" "5000" }}
    78  {{- end }}