Skip to content

Commit 3df7e36

Browse files
authored
Merge pull request #176 from hemanthnakkina/switch-to-k8s
Add support for k8s provider
2 parents a6d47e3 + 63b4c0b commit 3df7e36

File tree

28 files changed

+1568
-252
lines changed

28 files changed

+1568
-252
lines changed

.github/assets/k8s/edge.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
software:
2+
charms:
3+
aodh-k8s:
4+
channel: 2024.1/edge
5+
barbican-k8s:
6+
channel: 2024.1/edge
7+
ceilometer-k8s:
8+
channel: 2024.1/edge
9+
cinder-ceph-k8s:
10+
channel: 2024.1/edge
11+
cinder-k8s:
12+
channel: 2024.1/edge
13+
designate-bind-k8s:
14+
channel: 9/edge
15+
designate-k8s:
16+
channel: 2024.1/edge
17+
glance-k8s:
18+
channel: 2024.1/edge
19+
gnocchi-k8s:
20+
channel: 2024.1/edge
21+
heat-k8s:
22+
channel: 2024.1/edge
23+
horizon-k8s:
24+
channel: 2024.1/edge
25+
keystone-k8s:
26+
channel: 2024.1/edge
27+
keystone-ldap-k8s:
28+
channel: 2024.1/edge
29+
magnum-k8s:
30+
channel: 2024.1/edge
31+
neutron-k8s:
32+
channel: 2024.1/edge
33+
nova-k8s:
34+
channel: 2024.1/edge
35+
octavia-k8s:
36+
channel: 2024.1/edge
37+
openstack-exporter-k8s:
38+
channel: 2024.1/edge
39+
openstack-hypervisor:
40+
channel: 2024.1/edge
41+
config:
42+
snap-channel: 2024.1/edge
43+
ovn-central-k8s:
44+
channel: 24.03/edge
45+
ovn-relay-k8s:
46+
channel: 24.03/edge
47+
placement-k8s:
48+
channel: 2024.1/edge
49+
sunbeam-clusterd:
50+
channel: 2024.1/edge
51+
config:
52+
snap-channel: 2024.1/edge
53+
sunbeam-machine:
54+
channel: 2024.1/edge
55+
tempest-k8s:
56+
channel: 2024.1/edge
57+
microceph:
58+
channel: reef/edge
59+
# Required for k8s until the rabbitmq-k8s stable is updated
60+
rabbitmq-k8s:
61+
channel: 3.12/candidate
+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Test sunbeam with k8s operator
2+
3+
on:
4+
workflow_dispatch:
5+
input:
6+
k8s-provider:
7+
description: Select k8s provider
8+
required: true
9+
default: k8s
10+
type: choice
11+
options:
12+
- microk8s
13+
- k8s
14+
outputs:
15+
snap:
16+
description: "Filename of the built snap artifact"
17+
value: local-${{ jobs.build.outputs.snap }}
18+
19+
jobs:
20+
build:
21+
name: Build snap
22+
runs-on: ubuntu-latest
23+
outputs:
24+
snap: ${{ steps.snapcraft.outputs.snap }}
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v3
28+
29+
- name: Build snap locally
30+
uses: snapcore/action-build@v1
31+
id: snapcraft
32+
33+
- name: Upload locally built snap artifact
34+
uses: actions/upload-artifact@v3
35+
with:
36+
name: local-${{ steps.snapcraft.outputs.snap }}
37+
path: ${{ steps.snapcraft.outputs.snap }}
38+
39+
functional-test:
40+
needs: build
41+
name: Functional test
42+
runs-on: [self-hosted, large, jammy, x64]
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
- name: Download snap artifact
47+
id: download
48+
uses: actions/download-artifact@v3
49+
with:
50+
name: local-${{ needs.build.outputs.snap }}
51+
- name: test
52+
run: |
53+
export COLUMNS=256
54+
sudo snap install ${{ needs.build.outputs.snap }} --dangerous
55+
sudo snap set openstack k8s.provider={{ inputs.k8s-provider }}
56+
openstack.sunbeam prepare-node-script | bash -x
57+
sudo snap connect openstack:juju-bin juju:juju-bin
58+
sudo snap connect openstack:dot-local-share-juju
59+
sudo snap connect openstack:dot-config-openstack
60+
sudo snap connect openstack:dot-local-share-openstack
61+
sg snap_daemon "openstack.sunbeam cluster bootstrap --manifest .github/assets/k8s/edge.yml --accept-defaults --topology single --database single"
62+
sg snap_daemon "openstack.sunbeam cluster list"
63+
# Note: Moving configure before enabling caas just to ensure caas images are not downloaded
64+
# To download caas image, require ports to open on firewall to access fedora images.
65+
sg snap_daemon "openstack.sunbeam configure -a"
66+
sg snap_daemon "openstack.sunbeam launch"
67+
sg snap_daemon "openstack.sunbeam enable orchestration"
68+
# sg snap_daemon "openstack.sunbeam enable loadbalancer"
69+
# sg snap_daemon "openstack.sunbeam enable dns --nameservers=testing.github."
70+
sg snap_daemon "openstack.sunbeam enable telemetry"
71+
sg snap_daemon "openstack.sunbeam enable observability"
72+
sg snap_daemon "openstack.sunbeam enable vault"
73+
sg snap_daemon "openstack.sunbeam enable secrets"
74+
sg snap_daemon "openstack.sunbeam enable caas"
75+
# sg snap_daemon "openstack.sunbeam enable validation"
76+
# If smoke tests fails, logs should be collected via sunbeam command in "Collect logs"
77+
# sg snap_daemon "openstack.sunbeam validation run smoke"
78+
# sg snap_daemon "openstack.sunbeam validation run --output tempest_validation.log"
79+
sg snap_daemon "openstack.sunbeam disable caas"
80+
sg snap_daemon "openstack.sunbeam disable secrets"
81+
sg snap_daemon "openstack.sunbeam disable vault"
82+
# Commented disabling observability due to LP#1998282
83+
# sg snap_daemon "openstack.sunbeam disable observability"
84+
# sg snap_daemon "openstack.sunbeam disable telemetry"
85+
# sg snap_daemon "openstack.sunbeam disable dns"
86+
# sg snap_daemon "openstack.sunbeam disable loadbalancer"
87+
sg snap_daemon "openstack.sunbeam disable orchestration"
88+
# sg snap_daemon "openstack.sunbeam disable validation"
89+
90+
- name: Collect logs
91+
if: always()
92+
run: |
93+
mkdir -p logs
94+
models=$(juju models --format json | jq -r .models[].name)
95+
for model in $models; do name=$(echo $model | cut -d/ -f2); juju status -m $model -o logs/$name.yaml; cat logs/$name.yaml; done
96+
for model in $models; do name=$(echo $model | cut -d/ -f2); juju debug-log -m $model --replay > logs/$name-debug-log.txt; done
97+
cp -rf $HOME/snap/openstack/common/logs/*.log logs/
98+
# if test -f tempest_validation.log; then cp tempest_validation.log logs/; fi
99+
- name: Upload logs
100+
if: always()
101+
uses: actions/upload-artifact@v3
102+
with:
103+
name: Sunbeam logs
104+
path: logs
105+
retention-days: 30
106+
- name: Setup tmate session
107+
if: ${{ failure() && runner.debug }}
108+
uses: canonical/action-tmate@main

cloud/etc/deploy-k8s/main.tf

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2023 Canonical Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
terraform {
17+
18+
required_providers {
19+
juju = {
20+
source = "juju/juju"
21+
version = "= 0.11.0"
22+
}
23+
}
24+
25+
}
26+
27+
provider "juju" {}
28+
29+
data "juju_model" "machine_model" {
30+
name = var.machine_model
31+
}
32+
33+
resource "juju_application" "k8s" {
34+
name = "k8s"
35+
model = data.juju_model.machine_model.name
36+
units = length(var.machine_ids) # need to manage the number of units
37+
38+
charm {
39+
name = "k8s"
40+
channel = var.k8s_channel
41+
revision = var.k8s_revision
42+
base = "ubuntu@22.04"
43+
}
44+
45+
config = merge({
46+
channel = var.k8s_snap_channel
47+
}, var.k8s_config)
48+
}

cloud/etc/deploy-k8s/variables.tf

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Copyright (c) 2023 Canonical Ltd.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12+
# implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
variable "k8s_channel" {
17+
description = "Operator channel for k8s deployment"
18+
type = string
19+
default = "latest/edge"
20+
}
21+
22+
variable "k8s_revision" {
23+
description = "Operator channel revision for k8s deployment"
24+
type = number
25+
default = null
26+
}
27+
28+
variable "k8s_config" {
29+
description = "Operator config for k8s deployment"
30+
type = map(string)
31+
default = {}
32+
}
33+
34+
variable "k8s_snap_channel" {
35+
description = "K8S snap channel to deploy, not the operator channel"
36+
default = "latest/edge"
37+
}
38+
39+
variable "machine_ids" {
40+
description = "List of machine ids to include"
41+
type = list(string)
42+
default = []
43+
}
44+
45+
variable "machine_model" {
46+
description = "Model to deploy to"
47+
type = string
48+
}

cloud/etc/deploy-microk8s/variables.tf

-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ variable "addons" {
5656
metallb = "10.20.21.1-10.20.21.10"
5757
}
5858
}
59-

snap/snapcraft.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ parts:
145145
stage:
146146
- bin/terraform
147147

148-
terraform-microk8s-plan:
148+
terraform-sunbeam-plans:
149149
after: [terraform]
150150
plugin: dump
151151
source: cloud/

sunbeam-python/sunbeam/commands/juju.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def _juju_cmd(self, *args):
7373
do not need to worry about the format or the juju command that should
7474
be used.
7575
76-
For example, to run the juju bootstrap microk8s, this method should
76+
For example, to run the juju bootstrap k8s, this method should
7777
be invoked as:
7878
79-
self._juju_cmd('bootstrap', 'microk8s')
79+
self._juju_cmd('bootstrap', 'k8s')
8080
8181
Any results from running with json are returned after being parsed.
8282
Subprocess execution errors are raised to the calling code.

0 commit comments

Comments
 (0)