mirror of
https://github.com/ubuntu/microk8s.git
synced 2021-05-23 02:23:41 +03:00
Portainer add-on (#1650)
This commit is contained in:
23
microk8s-resources/actions/disable.portainer.sh
Executable file
23
microk8s-resources/actions/disable.portainer.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source $SNAP/actions/common/utils.sh
|
||||
|
||||
NAMESPACE_PTR="portainer"
|
||||
|
||||
MANIFEST_PTR="https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml"
|
||||
|
||||
KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"
|
||||
|
||||
KUBECTL_DELETE_ARGS="--wait=true --timeout=180s --ignore-not-found=true"
|
||||
|
||||
echo "Disabling Portainer"
|
||||
|
||||
# unload the the manifests
|
||||
$KUBECTL delete $KUBECTL_DELETE_ARGS -n $NAMESPACE_PTR -f "$MANIFEST_PTR" > /dev/null 2>&1
|
||||
|
||||
# delete the "portainer" namespace
|
||||
$KUBECTL delete $KUBECTL_DELETE_ARGS namespace "$NAMESPACE_PTR" > /dev/null 2>&1 || true
|
||||
|
||||
echo "Portainer is disabled"
|
||||
31
microk8s-resources/actions/enable.portainer.sh
Executable file
31
microk8s-resources/actions/enable.portainer.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source $SNAP/actions/common/utils.sh
|
||||
|
||||
NAMESPACE_PTR="portainer"
|
||||
|
||||
MANIFEST_PTR="https://raw.githubusercontent.com/portainer/k8s/master/deploy/manifests/portainer/portainer.yaml"
|
||||
|
||||
KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"
|
||||
|
||||
microk8s enable storage
|
||||
microk8s enable dns
|
||||
|
||||
echo "Enabling portainer"
|
||||
|
||||
|
||||
# make sure the "portainer" namespace exists
|
||||
$KUBECTL create namespace "$NAMESPACE_PTR" > /dev/null 2>&1 || true
|
||||
|
||||
# load the CRD and wait for it to be installed
|
||||
$KUBECTL apply -f "$MANIFEST_PTR"
|
||||
# change storage class that is default
|
||||
#PVCNAME= "$KUBECTL get pvc -n "$NAMESPACE_PTR" -o jsonpath="{.items[0].metadata.name}""
|
||||
SC=$($KUBECTL get sc | grep default | awk '{print $1}')
|
||||
$KUBECTL patch pvc portainer -n "$NAMESPACE_PTR" -p '{ "spec": { "storageClassName": "'${SC}'"}}'
|
||||
|
||||
|
||||
# print a final help message
|
||||
echo "Portainer has been installed"
|
||||
@@ -166,10 +166,19 @@ microk8s-addons:
|
||||
check_status: "deployment.apps/ambassador-operator"
|
||||
supported_architectures:
|
||||
- amd64
|
||||
|
||||
- name: "ha-cluster"
|
||||
description: "Configure high availability on the current node"
|
||||
version: "0.1.0"
|
||||
check_status: "${SNAP_DATA}/var/lock/ha-cluster"
|
||||
supported_architectures:
|
||||
- arm64
|
||||
- amd64
|
||||
- amd64
|
||||
|
||||
- name: "portainer"
|
||||
description: "Portainer UI for your Kubernetes cluster"
|
||||
version: "2.0.0"
|
||||
check_status: "pod/portainer"
|
||||
supported_architectures:
|
||||
- arm64
|
||||
- amd64
|
||||
|
||||
@@ -22,6 +22,7 @@ from validators import (
|
||||
validate_kubeflow,
|
||||
validate_metallb_config,
|
||||
validate_prometheus,
|
||||
validate_portainer,
|
||||
)
|
||||
from utils import (
|
||||
microk8s_enable,
|
||||
@@ -322,6 +323,17 @@ class TestAddons(object):
|
||||
print("Disabling Multus")
|
||||
microk8s_disable("multus")
|
||||
|
||||
def test_portainer(self):
|
||||
"""
|
||||
Sets up and validates Portainer.
|
||||
"""
|
||||
print("Enabling Portainer")
|
||||
microk8s_enable("portainer")
|
||||
print("Validating Portainer")
|
||||
validate_portainer()
|
||||
print("Disabling Portainer")
|
||||
microk8s_disable("portainer")
|
||||
|
||||
def test_backup_restore(self):
|
||||
"""
|
||||
Test backup and restore commands.
|
||||
|
||||
@@ -488,3 +488,10 @@ def validate_metallb_config(ip_ranges="192.168.0.105"):
|
||||
out = kubectl("get configmap config -n metallb-system -o jsonpath='{.data.config}'")
|
||||
for ip_range in ip_ranges.split(","):
|
||||
assert ip_range in out
|
||||
|
||||
|
||||
def validate_portainer():
|
||||
"""
|
||||
Validate portainer
|
||||
"""
|
||||
wait_for_pod_state("", "portainer", "running", label="app.kubernetes.io/name=portainer")
|
||||
|
||||
Reference in New Issue
Block a user