Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s hyperconverged support #145

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}

8 changes: 1 addition & 7 deletions 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 All @@ -17,11 +17,5 @@ applications:
num_units: __NUM_K8S_WORKER_UNITS__
options:
channel: *k8s_channel
openstack-integrator:
charm: __CHARM_STORE____CHARM_CS_NS____CHARM_CH_PREFIX__openstack-integrator
constraints: mem=1G
num_units: 1
relations:
- [ 'kubernetes-control-plane:kube-control', 'kubernetes-worker:kube-control' ]
- [ 'openstack-integrator:clients', 'kubernetes-control-plane:openstack' ]
- [ 'openstack-integrator:clients', 'kubernetes-worker:openstack' ]
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
13 changes: 8 additions & 5 deletions kubernetes/pipeline/02configure
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ 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
MOD_OVERLAYS+=( "kubernetes/k8s-openstack-integrator-trust.yaml" )
JUJU_DEPLOY_OPTS=" --trust"
if ! is_hyperconverged; then
MOD_OVERLAYS+=( "kubernetes/k8s-openstack-integrator.yaml" )
if ! has_opt --no-trust && [[ ! "$JUJU_VERSION" < "2.7" ]]; then
MOD_OVERLAYS+=( "kubernetes/k8s-openstack-integrator-trust.yaml" )
JUJU_DEPLOY_OPTS=" --trust"
fi
fi

# Skip processing input if it includes exclusive passthrough options
Expand Down Expand Up @@ -167,7 +170,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 +196,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 ]
8 changes: 8 additions & 0 deletions overlays/kubernetes/k8s-openstack-integrator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
applications:
openstack-integrator:
charm: __CHARM_STORE____CHARM_CS_NS____CHARM_CH_PREFIX__openstack-integrator
constraints: mem=1G
num_units: 1
relations:
- [ 'openstack-integrator:clients', 'kubernetes-control-plane:openstack' ]
- [ 'openstack-integrator:clients', 'kubernetes-worker:openstack' ]
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__