Skip to content

Commit 73fe5c7

Browse files
authored
Merge pull request #20 from stackhpc/2024.12.1-sync
2024.12.1 sync
2 parents 8ec5092 + 007d89c commit 73fe5c7

File tree

23 files changed

+485
-68
lines changed

23 files changed

+485
-68
lines changed

.github/actions/setup/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ runs:
107107
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT"
108108
ansible-galaxy install -f -r requirements.yml
109109
110+
- name: Generate secrets for environment
111+
shell: bash
112+
run: |
113+
set -e
114+
source ci.env
115+
source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT"
116+
./bin/generate-secrets
117+
110118
# Generate and append the S3 credential to the CI environment file
111119
- name: Configure S3 lock
112120
id: s3-lock-config

.github/workflows/update-dependencies.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
jobs:
1212
propose_github_release_updates:
1313
runs-on: ubuntu-latest
14+
if: github.repository == 'azimuth-cloud/azimuth-config'
1415
strategy:
1516
matrix:
1617
include:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
.python-version
66
/clouds.yaml*
77
tilt-settings.yaml
8+
# Ignore generated secrets in demo and CI environments
9+
environments/demo/inventory/group_vars/all/secrets.yml
10+
.github/environments/**/secrets.yml

Tiltfile

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ TILT_IMAGES_UNAPPLY = os.path.abspath("./bin/tilt-images-unapply")
88
# Allow the use of the azimuth-dev context
99
allow_k8s_contexts("azimuth")
1010

11+
# Increase the timeout for applying to Kubernetes
12+
update_settings(k8s_upsert_timeout_secs = 600)
1113

1214
def deep_merge(dict1, dict2):
1315
"""
@@ -34,6 +36,13 @@ if not os.path.exists(SETTINGS_FILE):
3436
# Load the settings
3537
settings = deep_merge(
3638
{
39+
# The engine that will be used to build container images for your changes
40+
# Supported options are docker, podman
41+
"build_engine": "docker",
42+
# The engine that will be used to mirror container images when required
43+
# Supported options are skopeo (recommended), docker, podman
44+
# Defaults to the build engine
45+
# "mirror_engine": "skopeo",
3746
# The components that will be managed by Tilt, if locally available
3847
# By default, we search for local checkouts as siblings of this checkout
3948
"components": {
@@ -101,27 +110,23 @@ def build_image(name, context, build_args = None):
101110
"""
102111
Defines an image build and returns the image name.
103112
"""
113+
build_engine = settings["build_engine"]
114+
if build_engine not in ["docker", "podman"]:
115+
fail("unknown build engine - %s" % build_engine)
104116
image = image_name(name)
105-
# The Azimuth CaaS operator relies on the .git folder to be in the Docker build context
106-
# This is because it uses pbr for versioning
107-
# Unfortunately, Tilt's docker_build function _always_ ignores the .git directory :-(
117+
# Some of the Azimuth components rely on the .git folder to be in the build context (pbr)
118+
# Unfortunately, Tilt's {docker,podman}_build functions _always_ ignores the .git directory
108119
# So we use a custom build command
109-
build_command = [
110-
"docker",
111-
"build",
112-
"-t",
113-
"$EXPECTED_REF",
114-
"--platform",
115-
"linux/amd64",
116-
context,
117-
]
118-
if build_args:
119-
for arg_name, arg_value in build_args.items():
120-
build_command.extend([
121-
"--build-arg",
122-
"'%s=%s'" % (arg_name, arg_value),
123-
])
124-
custom_build(image, " ".join(build_command), [context])
120+
build_args = " ".join([
121+
item
122+
for arg_name, arg_value in (build_args or {}).items()
123+
for item in ["--build-arg", "'%s=%s'" % (arg_name, arg_value)]
124+
])
125+
build_command = (
126+
"%s build -t $EXPECTED_REF --platform linux/amd64 %s %s && " % (build_engine, build_args, context) +
127+
"%s push $EXPECTED_REF" % build_engine
128+
)
129+
custom_build(image, build_command, [context], skips_local_docker = True)
125130
return image
126131

127132

@@ -130,14 +135,18 @@ def mirror_image(name, source_image):
130135
Defines a mirrored image and returns the image name.
131136
"""
132137
image = image_name(name)
133-
custom_build(
134-
image,
135-
(
136-
"docker pull --platform linux/amd64 {source_image} && " +
137-
"docker tag {source_image} $EXPECTED_REF"
138-
).format(source_image = source_image),
139-
[]
140-
)
138+
mirror_engine = settings.get("mirror_engine") or settings["build_engine"]
139+
if mirror_engine in ["docker", "podman"]:
140+
mirror_command = (
141+
"%s pull --platform linux/amd64 %s && " % (mirror_engine, source_image) +
142+
"%s tag %s $EXPECTED_REF && " % (mirror_engine, source_image) +
143+
"%s push $EXPECTED_REF" % mirror_engine
144+
)
145+
elif mirror_engine == "skopeo":
146+
mirror_command = "skopeo copy --all docker://%s docker://$EXPECTED_REF" % source_image
147+
else:
148+
fail("unrecognised mirror engine - %s" % mirror_engine)
149+
custom_build(image, mirror_command, [], skips_local_docker = True)
141150
return image
142151

143152

bin/generate-secrets

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env bash
2+
3+
#####
4+
## This script generates a secrets file for an environment.
5+
##
6+
## The environment can either be given as an argument or activated.
7+
#####
8+
9+
set -eo pipefail
10+
11+
12+
# Parse the command line arguments
13+
# The environment defaults to the active environment, if set
14+
COMMAND_ENVIRONMENT="${AZIMUTH_CONFIG_ENVIRONMENT:-""}"
15+
FORCE_OVERWRITE=
16+
while [[ $# -gt 0 ]]; do
17+
case $1 in
18+
-f|--force)
19+
FORCE_OVERWRITE="yes"
20+
shift
21+
;;
22+
*)
23+
COMMAND_ENVIRONMENT="$1"
24+
shift
25+
;;
26+
esac
27+
done
28+
29+
# If the environment is unknown at this point, bail
30+
if [ -z "$COMMAND_ENVIRONMENT" ]; then
31+
echo "Target environment must either be specified as an argument or activated" >&2
32+
exit 1
33+
fi
34+
35+
# Work out where the secrets file for the specified environment lives
36+
CONFIG_ROOT="$(dirname $(dirname $(realpath ${BASH_SOURCE[0]:-${(%):-%x}})))"
37+
# We check environments and .github/environments, as in activate
38+
if [ -d "$CONFIG_ROOT/environments/$COMMAND_ENVIRONMENT" ]; then
39+
CONFIG_ENVIRONMENT_ROOT="$CONFIG_ROOT/environments/$COMMAND_ENVIRONMENT"
40+
elif [ -d "$CONFIG_ROOT/.github/environments/$COMMAND_ENVIRONMENT" ]; then
41+
CONFIG_ENVIRONMENT_ROOT="$CONFIG_ROOT/.github/environments/$COMMAND_ENVIRONMENT"
42+
else
43+
echo "Unrecognised config environment '$COMMAND_ENVIRONMENT'" >&2
44+
exit 1
45+
fi
46+
SECRETS_FILE="$CONFIG_ENVIRONMENT_ROOT/inventory/group_vars/all/secrets.yml"
47+
echo "Writing secrets to $SECRETS_FILE"
48+
49+
# If the secrets file already exists, do not overwrite it unless explicitly requested
50+
if [ -f "$SECRETS_FILE" ]; then
51+
if [ "$FORCE_OVERWRITE" = "yes" ]; then
52+
echo "$SECRETS_FILE already exists - overwriting"
53+
else
54+
echo "$SECRETS_FILE already exists - will not overwrite" >&2
55+
exit 1
56+
fi
57+
fi
58+
59+
# Write the secrets file, making sure the directory exists first
60+
mkdir -p "$(dirname $SECRETS_FILE)"
61+
cat <<EOF > $SECRETS_FILE
62+
#####
63+
# This file contains secrets for the $COMMAND_ENVIRONMENT environment
64+
#
65+
# It should be encrypted if stored in version control
66+
# https://azimuth-config.readthedocs.io/en/stable/repository/secrets/
67+
#####
68+
69+
# https://azimuth-config.readthedocs.io/en/stable/configuration/05-secret-key/
70+
# The secret key for signing Azimuth cookies
71+
azimuth_secret_key: "$(openssl rand -hex 32)"
72+
73+
# https://azimuth-config.readthedocs.io/en/stable/configuration/07-platform-identity/#keycloak-admin-password
74+
# The admin password for the Keycloak master realm
75+
keycloak_admin_password: "$(openssl rand -hex 16)"
76+
77+
# https://azimuth-config.readthedocs.io/en/stable/configuration/08-zenith/
78+
# The secret key for signing Zenith registrar tokens
79+
zenith_registrar_subdomain_token_signing_key: "$(openssl rand -hex 32)"
80+
81+
# https://azimuth-config.readthedocs.io/en/stable/configuration/10-kubernetes-clusters/#harbor-registry
82+
# The password for the Harbor admin account
83+
harbor_admin_password: "$(openssl rand -hex 16)"
84+
# The secret key for Harbor
85+
harbor_secret_key: "$(openssl rand -hex 8)"
86+
87+
# https://azimuth-config.readthedocs.io/en/stable/configuration/14-monitoring/#accessing-web-interfaces
88+
# The admin password for Azimuth administrative dashboards
89+
admin_dashboard_ingress_basic_auth_password: "$(openssl rand -hex 16)"
90+
EOF

bin/kube-connect

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

33
#####
4-
## This script uses Tilt (tilt.dev) to allow easier code development on the
5-
## currently activated environment
4+
## This script allows access to the Azimuth Kubernetes cluster from the machine
5+
## where the script is executed by using a SOCKS proxy
66
#####
77

88
set -eo pipefail
@@ -80,7 +80,7 @@ if [ "$install_mode" = "ha" ]; then
8080
cluster_name="$(ansible_variable capi_cluster_release_name)"
8181
kubeconfig_arg="KUBECONFIG=./kubeconfig-${cluster_name}.yaml"
8282
fi
83-
"$AZIMUTH_CONFIG_ROOT/bin/seed-ssh" \
83+
"$AZIMUTH_CONFIG_ROOT/bin/seed-ssh" -q \
8484
$kubeconfig_arg \
8585
kubectl config view --raw > "$kubeconfig"
8686

@@ -104,7 +104,7 @@ kubectl config rename-context $ctx azimuth --kubeconfig $kubeconfig >/dev/null
104104

105105
# Launch the SOCKS proxy and store the PID
106106
echo "Starting SOCKS proxy..." >&2
107-
"$AZIMUTH_CONFIG_ROOT/bin/seed-ssh" -D $socks_port -N &
107+
"$AZIMUTH_CONFIG_ROOT/bin/seed-ssh" -q -D $socks_port -N &
108108
socks_pid="$!"
109109
# Wait a few seconds and check that the process is running
110110
sleep 5

bin/seed-ssh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if [ -z "$AZIMUTH_CONFIG_ROOT" ] || [ -z "$AZIMUTH_CONFIG_ENVIRONMENT_ROOT" ]; t
1313
exit 1
1414
fi
1515

16-
1716
ansible_variable() {
1817
ANSIBLE_LOAD_CALLBACK_PLUGINS=true \
1918
ANSIBLE_STDOUT_CALLBACK=json \
@@ -22,6 +21,15 @@ ansible_variable() {
2221
jq -r -R "fromjson? | .plays[0].tasks[0].hosts.localhost.$1"
2322
}
2423

24+
tf_init() {
25+
ansible_variable terraform_backend_config > "$terraform_dir/backend_config.json"
26+
$terraform_binary_path \
27+
-chdir="$terraform_dir" \
28+
init \
29+
-input=false \
30+
-reconfigure \
31+
-backend-config=$terraform_dir/backend_config.json
32+
}
2533

2634
# Add the Terraform binary directory to the PATH, so we can use it if it was
2735
# downloaded as part of a provision
@@ -45,6 +53,20 @@ fi
4553
work_dir="$(ansible_variable work_directory)/seed-ssh"
4654
mkdir -p "$work_dir"
4755

56+
# Check if quiet mode (-q) was passed to SSH command
57+
# so that we can suppress other output elsewhere too
58+
QUIET_MODE=false
59+
for arg in $@; do
60+
if [[ ! $arg == -* ]]; then
61+
# Break if we encounter a non-flag arg since
62+
# this is likely a command to run within the SSH
63+
# session instead of an arg intended for SSH client
64+
break
65+
elif [[ $arg == "-q" ]]; then
66+
QUIET_MODE=true
67+
fi
68+
done
69+
4870
# Initialise the OpenTofu backend
4971
terraform_backend_type="$(ansible_variable terraform_backend_type)"
5072
if [ "$terraform_backend_type" = "local" ]; then
@@ -60,13 +82,12 @@ terraform {
6082
backend "${terraform_backend_type}" {}
6183
}
6284
EOF
63-
ansible_variable terraform_backend_config > "$terraform_dir/backend_config.json"
64-
$terraform_binary_path \
65-
-chdir="$terraform_dir" \
66-
init \
67-
-input=false \
68-
-reconfigure \
69-
-backend-config=$terraform_dir/backend_config.json
85+
# If -q (quiet) is passed to ssh then also suppress terraform / tofu output
86+
if [[ $QUIET_MODE == "true" ]]; then
87+
tf_init > /dev/null
88+
else
89+
tf_init
90+
fi
7091
fi
7192

7293
# Read the required variables from the Terraform state

docs/configuration/03-kubernetes-config.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ etcd is extremely sensitive to write latency.
130130

131131
Azimuth is able to configure Kubernetes nodes, both for the HA cluster and tenant clusters, so
132132
that etcd is on a separate block device. This block device can be of a different volume type to
133-
the root disk, allowing efficient use of SSD-backed storage. When supported by the flavor, the
134-
etcd block device can also use local disk even if the root volume is from Cinder.
133+
the root disk, allowing efficient use of SSD-backed storage. When the flavor has an ephemeral storage
134+
allocation, and the ephemeral storage capacity is at least as large as the desired etcd block device
135+
size, the etcd block device can also use local disk even if the root volume is from Cinder.
135136

136137
!!! tip "Use local disk for etcd whenever possible"
137138

0 commit comments

Comments
 (0)