1
0
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:
balasu
2020-11-16 20:57:01 +05:30
committed by GitHub
parent f9cbfdfd20
commit 3a464db0bf
5 changed files with 83 additions and 1 deletions

View 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"

View 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"

View File

@@ -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

View File

@@ -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.

View File

@@ -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")