Skip to content

Commit

Permalink
Add k8s hyperconverged support
Browse files Browse the repository at this point in the history
Resolves: #144
  • Loading branch information
dosaboy committed Oct 26, 2023
1 parent 4a98117 commit 107fdd1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 17 deletions.
13 changes: 11 additions & 2 deletions common/generate_bundle_base
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,17 @@ readarray -t application_list < <("$MOD_DIR/../tools/juju-bundle-applications.py
# Generate placement overlay for use with MAAS provider
if ${MASTER_OPTS[HYPERCONVERGED_DEPLOYMENT]}; then
cp $MOD_DIR/overlays/unit_placement/header.yaml.template $bundles_dir/unit-placement.yaml
# these two represent total machines since e.g. ceph is deployed on compute but compute and gateway are never colocated
num_placement_machines=$((${MOD_PARAMS[__NUM_NEUTRON_GATEWAY_UNITS__]}+${MOD_PARAMS[__NUM_COMPUTE_UNITS__]}))
if [[ $MOD_NAME = openstack ]]; then
# these two represent total machines since e.g. ceph is deployed on compute but compute and gateway are never colocated
num_placement_machines=$((${MOD_PARAMS[__NUM_NEUTRON_GATEWAY_UNITS__]}+${MOD_PARAMS[__NUM_COMPUTE_UNITS__]}))
elif [[ $MOD_NAME = kubernetes ]]; then
num_placement_machines=$((${MOD_PARAMS[__NUM_K8S_CONTROL_PLANE_UNITS__]}+${MOD_PARAMS[__NUM_K8S_WORKER_UNITS__]}))
elif [[ $MOD_NAME = ceph ]]; then
num_placement_machines=$((${MOD_PARAMS[__NUM_CEPH_OSD_UNITS__]}))
else
echo "ERROR: module '$MOD_NAME' does not yet have support for hyperconverged mode" 1>&2
exit 1
fi
# detect all apps used and generate placement info by doing:
# * search for all app names in generated bundles/overlays
# * search unit_placement template with same name
Expand Down
10 changes: 10 additions & 0 deletions common/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -830,3 +830,13 @@ get_local_upstream_dns ()
(($?==0)) && echo $server && return 0
echo "10.198.200.1" # stsstack upstream dns
}
is_hyperconverged ()
{
if has_opt --hyperconverged || ${MASTER_OPTS[HYPERCONVERGED_DEPLOYMENT]}; then
return 0
else
return 1
fi
}
2 changes: 1 addition & 1 deletion kubernetes/kubernetes.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ applications:
charm: __CHARM_STORE____CHARM_CS_NS____CHARM_CH_PREFIX__kubernetes-control-plane
constraints: mem=2G
expose: true
num_units: __NUM_K8S_MASTER_UNITS__
num_units: __NUM_K8S_CONTROL_PLANE_UNITS__
options:
channel: *k8s_channel
kubernetes-worker:
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/module_defaults
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
MOD_PARAMS[__K8S_CHANNEL__]="latest/stable"
MOD_PARAMS[__NUM_ETCD_UNITS__]=1
MOD_PARAMS[__NUM_EASYRSA_UNITS__]=1
MOD_PARAMS[__NUM_K8S_MASTER_UNITS__]=1
MOD_PARAMS[__NUM_K8S_CONTROL_PLANE_UNITS__]=1
MOD_PARAMS[__NUM_K8S_WORKER_UNITS__]=2
MOD_PARAMS[__NUM_K8S_LB_UNITS__]=1
MOD_PARAMS[__ETCD_SNAP_CHANNEL__]='latest/stable'
Expand Down
6 changes: 3 additions & 3 deletions kubernetes/pipeline/02configure
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fi

# See https://bugs.launchpad.net/juju/+bug/1849636 for reason why we
# need min 2.7
if ! has_opt --no-trust && [[ ! "$JUJU_VERSION" < "2.7" ]]; then
if ! is_hyperconverged && ! has_opt --no-trust && [[ ! "$JUJU_VERSION" < "2.7" ]]; then
MOD_OVERLAYS+=( "kubernetes/k8s-openstack-integrator-trust.yaml" )
JUJU_DEPLOY_OPTS=" --trust"
fi
Expand Down Expand Up @@ -167,7 +167,7 @@ do
echo "ERROR: you can't do --lb-ha and --control-plane-ha at the same time."
exit 1
fi
get_units $1 __NUM_K8S_MASTER_UNITS__ 3
get_units $1 __NUM_K8S_CONTROL_PLANE_UNITS__ 3
MOD_OVERLAYS+=( "kubernetes/k8s-control-plane-ha.yaml" )
check_hacluster_channel
;;
Expand All @@ -193,7 +193,7 @@ do
shift
;;
--num-control-planes) #__OPT__type:<int>
MOD_PARAMS[__NUM_K8S_MASTER_UNITS__]=$2
MOD_PARAMS[__NUM_K8S_CONTROL_PLANE_UNITS__]=$2
shift
;;
--rook-ceph)
Expand Down
9 changes: 0 additions & 9 deletions openstack/pipeline/02configure
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ is_neutron_gateway_required ()
fi
}

is_hyperconverged ()
{
if has_opt --hyperconverged || ${MASTER_OPTS[HYPERCONVERGED_DEPLOYMENT]}; then
return 0
else
return 1
fi
}

# Needed in all cases
MOD_OVERLAYS+=(
openstack/glance.yaml
Expand Down
2 changes: 1 addition & 1 deletion overlays/kubernetes/k8s-control-plane-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ applications:
kubernetes-control-plane-hacluster:
charm: __CHARM_STORE____CHARM_CS_NS____CHARM_CH_PREFIX__hacluster
options:
cluster_count: __NUM_K8S_MASTER_UNITS__
cluster_count: __NUM_K8S_CONTROL_PLANE_UNITS__
relations:
- [ kubernetes-control-plane-hacluster, kubernetes-control-plane ]
- [ kubernetes-control-plane:kube-api-endpoint, kubernetes-worker:kube-api-endpoint ]
3 changes: 3 additions & 0 deletions overlays/unit_placement/kubeapi-load-balancer.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kubeapi-load-balancer:
to:
__UNIT_PLACEMENT_LXD__.__UNITS__.__NUM_K8S_LB_UNITS__
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kubernetes-control-plane:
to:
__UNIT_PLACEMENT_METAL__.__UNITS__.__NUM_K8S_CONTROL_PLANE_UNITS__
4 changes: 4 additions & 0 deletions overlays/unit_placement/kubernetes-worker.yaml.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kubernetes-worker:
to:
__UNIT_PLACEMENT_METAL__.__MACHINE_OFFSET__.__NUM_K8S_CONTROL_PLANE_UNITS__
__UNIT_PLACEMENT_METAL__.__UNITS__.__NUM_K8S_WORKER_UNITS__

0 comments on commit 107fdd1

Please sign in to comment.