summaryrefslogtreecommitdiffstats
path: root/ansible/roles/ansible-vvp-templates/templates/configmaps/site-certificate-configmap.yaml.j2
blob: 2d567410452b5beacf34fe695d2f2c722ddc5229 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: site-certificate
  namespace: default
data:
  site.crt: |
    {{ site_pem_cert|indent }}
  wrapper.sh: |
    #!/bin/sh
    # This script is meant to be used as a wrapper, so that it can be easily
    # used with docker or kubernetes' container command specification.
    #
    # Kubernetes' volumeMount creates symlinks for configMapped files at the
    # target directory.
    # Alpine's update-ca-certificates ignores symlinks.
    # So we must contrive to copy the contents of the mounted cert (a symlink)
    # into place as a normal file.
    dev_cert="${0%/*}/site.crt"
    echo >&2 "$0: Checking for site CA certificate at $dev_cert..."
    if [ -s "$dev_cert" ]; then
        echo >&2 "$0: Updating container CA certificate bundle with site certificate..."
        cp -L "$dev_cert" /usr/local/share/ca-certificates/
        update-ca-certificates
    else
        echo >&2 "$0: No site CA certificate found."
    fi
    echo >&2 "$0: Launching command: $@"
    exec "$@"