Skip to content

Commit

Permalink
Merge pull request #140 from dosaboy/issue/136
Browse files Browse the repository at this point in the history
juju 3.x support
  • Loading branch information
nicolasbock authored Sep 26, 2023
2 parents 800be49 + b4df1e3 commit df1dfde
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
12 changes: 12 additions & 0 deletions common/juju_helpers
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

is_juju_2 ()
{
juju --version| egrep -q "^2."
}

if is_juju_2; then
JUJU_RUN_CMD="run-action --wait"
else
JUJU_RUN_CMD="run"
fi
8 changes: 5 additions & 3 deletions kubernetes/tools/configure_docker_registry.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -ux

. $(dirname $0)/../common/juju_helpers

# Get the private docker-registry ip and port
ip=`juju run --unit docker-registry/0 'network-get website --ingress-address'`
port=`juju config docker-registry registry-port`
Expand All @@ -17,12 +19,12 @@ images=`kubectl get po --all-namespaces -o json | jq '.items[].spec.containers[]
# https://github.com/charmed-kubernetes/bundle/blob/master/container-images.txt
for image in ${images}; do
tag=${image/$old_image_registry/$registry};
juju run-action docker-registry/0 push image=$image tag=$tag --wait
juju $JUJU_RUN_CMD docker-registry/0 push image=$image tag=$tag
done

# Caveats: 1. Image names are different for coredns 2. Add pause container
juju run-action docker-registry/0 push image=$registry/coredns/coredns-amd64:1.6.7 tag=$registry/coredns/coredns:1.6.7 --wait
juju run-action docker-registry/0 push image=k8s.gcr.io/pause-amd64:3.2 tag=$registry/pause-amd64:3.2 --wait
juju $JUJU_RUN_CMD docker-registry/0 push image=$registry/coredns/coredns-amd64:1.6.7 tag=$registry/coredns/coredns:1.6.7
juju $JUJU_RUN_CMD docker-registry/0 push image=k8s.gcr.io/pause-amd64:3.2 tag=$registry/pause-amd64:3.2

# Update k8s to point to the private docker-registry
juju config kubernetes-control-plane image-registry=$registry
Expand Down
4 changes: 2 additions & 2 deletions openstack/pipeline/02configure
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ do
MOD_MSGS[octavia.0]="you need to to create an amphora image before you can use Octavia"
MOD_MSGS[octavia.1]="this can be done in one of two ways:"
MOD_MSGS[octavia.2]="run ./tools/upload_octavia_amphora_image.sh --release $release to use a pre-created image (recommended)"
MOD_MSGS[octavia.3]="create a new image with 'juju run-action octavia-diskimage-retrofit/0 --wait retrofit-image source-image=<uuid>' with id of image in Glance to use as base"
MOD_MSGS[octavia.3]="create a new image with 'juju $JUJU_RUN_CMD octavia-diskimage-retrofit/0 retrofit-image source-image=<uuid>' with id of image in Glance to use as base"
fi
if has_opt --octavia-ipv4; then
MOD_MSGS[octavia.4]="run tools/create_ipv4_octavia.sh"
Expand Down Expand Up @@ -653,7 +653,7 @@ do
MOD_OVERLAYS+=( "openstack/neutron-gateway.yaml" )
MOD_OVERLAYS=( ${MOD_OVERLAYS[@]/"openstack/neutron-openvswitch.yaml"} )
set -- $@ --no-ml2dns --ceph --ceph-rgw && cache $@
MOD_MSGS[ironic-conductor.0]="juju run-action ironic-conductor/leader set-temp-url-secret"
MOD_MSGS[ironic-conductor.0]="juju $JUJU_RUN_CMD ironic-conductor/leader set-temp-url-secret"
;;
--vault-ha*)
get_units $1 __NUM_VAULT_UNITS__ 3
Expand Down
4 changes: 3 additions & 1 deletion openstack/profiles/common
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

. $(dirname $0)/../common/juju_helpers

function upload_image {
src=$1
image_name=$2
Expand Down Expand Up @@ -155,5 +157,5 @@ function is_ksv3 () {
}

function heat_setup() {
juju run-action --wait heat/leader domain-setup
juju $JUJU_RUN_CMD heat/leader domain-setup
}
2 changes: 1 addition & 1 deletion openstack/profiles/default
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if ! ${BARE_METAL:-false} && ((`juju status neutron-gateway --format=json 2>/dev
fi

if ((`juju status ceilometer --format=json 2>/dev/null| jq '.machines| length'`)); then
juju run-action --wait ceilometer/leader ceilometer-upgrade
juju $JUJU_RUN_CMD ceilometer/leader ceilometer-upgrade
fi

if ((`juju status heat --format=json 2>/dev/null| jq '.machines| length'`)); then
Expand Down
4 changes: 3 additions & 1 deletion openstack/tools/configure_octavia.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash -eux
# NOTE: assumes that you have already added amphorae image to glance.

. $(dirname $0)/../common/juju_helpers

dout=`mktemp -d`
(
cd $dout
Expand Down Expand Up @@ -39,7 +41,7 @@ juju config octavia \
lb-mgmt-controller-cacert="$(base64 $dout/controller_ca.pem)" \
lb-mgmt-controller-cert="$(base64 $dout/controller_cert_bundle.pem)"

juju run-action octavia/leader configure-resources --wait
juju $JUJU_RUN_CMD octavia/leader configure-resources

# Add load-balancer_admin role for admin user
source $(readlink --canonicalize $(dirname $0))/../novarc
Expand Down
6 changes: 3 additions & 3 deletions openstack/tools/enable_samltestid.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash
#!/bin/bash -ex

set -ex
. $(dirname $0)/../common/juju_helpers

if ! juju show-application keystone-saml-mellon 2>&1; then
echo "Missing keystone-saml-mellon application"
exit 1
fi

juju run-action --format=json keystone-saml-mellon/0 get-sp-metadata --wait \
juju $JUJU_RUN_CMD --format=json keystone-saml-mellon/0 get-sp-metadata \
| jq -r '."unit-keystone-saml-mellon-0".results.output' \
> keystone-metadata.xml \
&& curl --form userfile=@"./keystone-metadata.xml" -s -o /dev/null \
Expand Down
4 changes: 3 additions & 1 deletion openstack/tools/install_local_ca.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -eu

. $(dirname $0)/../common/juju_helpers

validate_or_remove_ca() {
if [ -f $1 ]; then
if grep -Fxq -- "-----BEGIN CERTIFICATE-----" $1; then
Expand All @@ -17,7 +19,7 @@ if ((`juju status --format=json| jq -r '.applications[]| select(."charm-name"=="

if ! validate_or_remove_ca ${model_ca_cert_path}; then
echo "Fetching CA cert from vault" 1>&2
juju run-action --format=json vault/leader get-root-ca --wait | jq -r .[].results.output > $model_ca_cert_path
juju $JUJU_RUN_CMD --format=json vault/leader get-root-ca| jq -r .[].results.output > $model_ca_cert_path
if ! validate_or_remove_ca $model_ca_cert_path; then
echo "Didn't get a certificate from vault, check it's status and if necessary use ./tools/vault-unseal-and-authorise.sh" 1>&2
exit 1
Expand Down
4 changes: 3 additions & 1 deletion tools/vault-unseal-and-authorise.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash -ux

. $(dirname $0)/../common/juju_helpers

which vault > /dev/null || sudo snap install vault

model=`juju show-model --format=json| jq -r '.| keys[]'`
Expand Down Expand Up @@ -41,4 +43,4 @@ for addr in ${addrs[@]}; do
vault token create -ttl=10m
done
juju run-action $leader --wait authorize-charm token=$token
juju $JUJU_RUN_CMD $leader authorize-charm token=$token

0 comments on commit df1dfde

Please sign in to comment.