From 78435e4ff82470a37044ce45908692d78d140b63 Mon Sep 17 00:00:00 2001 From: Spyros Trigazis Date: Tue, 10 Mar 2020 19:55:28 +0100 Subject: [PATCH] Add fcct config for coreos user_data Until now we had only the output of the Fedora CoreOS Configuration Transpiler. Add a yaml that can transpile it to an ignition file. The current ignition file was generate with version v0.4.0: podman run --rm -v ./fcct-config.yaml:/config.fcc:z \ quay.io/coreos/fcct:v0.4.0 \ --pretty --strict --input /config.fcc > ./user_data.json story: 2005201 task: 39027 Change-Id: I5cb78aa625c926e101424c04573002d05ac82a59 Signed-off-by: Spyros Trigazis --- .../templates/fcct-config.yaml | 190 ++++++++++++++++++ .../templates/kubemaster.yaml | 16 +- .../templates/kubeminion.yaml | 16 +- .../templates/user_data.json | 133 +++++++----- 4 files changed, 284 insertions(+), 71 deletions(-) create mode 100644 magnum/drivers/k8s_fedora_coreos_v1/templates/fcct-config.yaml diff --git a/magnum/drivers/k8s_fedora_coreos_v1/templates/fcct-config.yaml b/magnum/drivers/k8s_fedora_coreos_v1/templates/fcct-config.yaml new file mode 100644 index 0000000000..cfe145880f --- /dev/null +++ b/magnum/drivers/k8s_fedora_coreos_v1/templates/fcct-config.yaml @@ -0,0 +1,190 @@ +# Fedora CoreOS Configuration +# +# To generate user_data.json you need to use [0]. +# For detailed instructions, please refer to the upstream documentation [1]. +# +# You can use podman or docker to generate the ignition formatted json: +# podman run --rm \ +# -v ./fcct-config.yaml:/config.fcc:z \ +# quay.io/coreos/fcct:release \ +# --pretty --strict --input /config.fcc > ./user_data.json +# +# [0] https://github.com/coreos/fcct +# [1] https://github.com/coreos/fedora-coreos-docs/blob/master/modules/ROOT/pages/producing-ign.adoc +variant: fcos +version: 1.0.0 +passwd: + users: + - name: core + ssh_authorized_keys: + - "__SSH_KEY_VALUE__" +storage: + directories: + - path: /var/lib/cloud/data + # 493 (decimal) == 755 (octal) + mode: 493 + user: + name: root + group: + name: root + - path: /var/lib/heat-cfntools + # 493 (decimal) == 755 (octal) + mode: 493 + user: + name: root + group: + name: root + files: + - path: /etc/hostname + # 420 (decimal) == 644 (octal) + mode: 420 + group: + name: root + user: + name: root + contents: + inline: | + __HOSTNAME__ + - path: /etc/pki/ca-trust/source/anchors/openstack-ca.pem + # 420 (decimal) == 644 (octal) + mode: 420 + user: + name: root + group: + name: root + contents: + inline: | + __OPENSTACK_CA__ + - path: /root/configure-agent-env.sh + # 448 (decimal) == 700 (octal) + mode: 448 + user: + name: root + group: + name: root + contents: + inline: | + #!/bin/bash + + set -x + set -e + set +u + + until [ -f /etc/pki/ca-trust/source/anchors/openstack-ca.pem ] + do + echo "waiting for /etc/pki/ca-trust/source/anchors/openstack-ca.pem" + sleep 3s + done + + /usr/bin/update-ca-trust + + HTTP_PROXY="__HTTP_PROXY__" + HTTPS_PROXY="__HTTPS_PROXY__" + NO_PROXY="__NO_PROXY__" + + if [ -n "${HTTP_PROXY}" ]; then + export HTTP_PROXY + echo "http_proxy=${HTTP_PROXY}" >> /etc/environment + fi + + if [ -n "${HTTPS_PROXY}" ]; then + export HTTPS_PROXY + echo "https_proxy=${HTTPS_PROXY}" >> /etc/environment + fi + + if [ -n "${NO_PROXY}" ]; then + export NO_PROXY + echo "no_proxy=${NO_PROXY}" >> /etc/environment + fi + + # Create a keypair for the heat-container-agent to + # access the node over ssh. It is useful to operate + # in host mount namespace and apply configuration. + id + mkdir -p /srv/magnum/.ssh + chmod 0700 /srv/magnum/.ssh + #touch /srv/magnum/.ssh/heat_agent_rsa + ssh-keygen -q -t rsa -N '' -f /tmp/heat_agent_rsa + mv /tmp/heat_agent_rsa /srv/magnum/.ssh/heat_agent_rsa + mv /tmp/heat_agent_rsa.pub /srv/magnum/.ssh/heat_agent_rsa.pub + chmod 0400 /srv/magnum/.ssh/heat_agent_rsa + chmod 0400 /srv/magnum/.ssh/heat_agent_rsa.pub + # Add the public to the host authorized_keys file. + mkdir -p /root/.ssh + chmod 0700 /root/.ssh + cat /srv/magnum/.ssh/heat_agent_rsa.pub > /root/.ssh/authorized_keys + # Add localost to know_hosts + ssh-keyscan 127.0.0.1 > /srv/magnum/.ssh/known_hosts + # ssh configguration file, to be specified with ssh -F + cat > /srv/magnum/.ssh/config <