Helm automated install tests (#9097)

* Update helm install doc in prep for automated tests

* Run make snips

* Fix linting issues

* Put helm install doc under test

* Update helm install test

* Spaces instead of tabs

* Fix gen and linting issues

* Add setup with no profile

* Qualify variable

* Suppress unreferenced var

* Use like, not elided

* Update snippets
This commit is contained in:
jacob-delgado 2021-04-07 18:34:12 -06:00 committed by GitHub
parent e575b768fa
commit a64fad4a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 180 additions and 23 deletions

View File

@ -6,7 +6,7 @@ weight: 27
keywords: [kubernetes,helm] keywords: [kubernetes,helm]
owner: istio/wg-environments-maintainers owner: istio/wg-environments-maintainers
icon: helm icon: helm
test: no test: yes
--- ---
Follow this guide to install and configure an Istio mesh using Follow this guide to install and configure an Istio mesh using
@ -55,20 +55,20 @@ to the missing `istio-token` volume.
1. Create a namespace `istio-system` for Istio components: 1. Create a namespace `istio-system` for Istio components:
{{< text bash >}} {{< text syntax=bash snip_id=create_istio_system_namespace >}}
$ kubectl create namespace istio-system $ kubectl create namespace istio-system
{{< /text >}} {{< /text >}}
1. Install the Istio base chart which contains cluster-wide resources used by 1. Install the Istio base chart which contains cluster-wide resources used by
the Istio control plane: the Istio control plane:
{{< text bash >}} {{< text syntax=bash snip_id=install_base >}}
$ helm install istio-base manifests/charts/base -n istio-system $ helm install istio-base manifests/charts/base -n istio-system
{{< /text >}} {{< /text >}}
1. Install the Istio discovery chart which deploys the `istiod` service: 1. Install the Istio discovery chart which deploys the `istiod` service:
{{< text bash >}} {{< text syntax=bash snip_id=install_discovery >}}
$ helm install istiod manifests/charts/istio-control/istio-discovery \ $ helm install istiod manifests/charts/istio-control/istio-discovery \
-n istio-system -n istio-system
{{< /text >}} {{< /text >}}
@ -76,7 +76,7 @@ to the missing `istio-token` volume.
1. (Optional) Install the Istio ingress gateway chart which contains the ingress 1. (Optional) Install the Istio ingress gateway chart which contains the ingress
gateway components: gateway components:
{{< text bash >}} {{< text syntax=bash snip_id=install_ingressgateway >}}
$ helm install istio-ingress manifests/charts/gateways/istio-ingress \ $ helm install istio-ingress manifests/charts/gateways/istio-ingress \
-n istio-system -n istio-system
{{< /text >}} {{< /text >}}
@ -84,7 +84,7 @@ to the missing `istio-token` volume.
1. (Optional) Install the Istio egress gateway chart which contains the egress 1. (Optional) Install the Istio egress gateway chart which contains the egress
gateway components: gateway components:
{{< text bash >}} {{< text syntax=bash snip_id=install_egressgateway >}}
$ helm install istio-egress manifests/charts/gateways/istio-egress \ $ helm install istio-egress manifests/charts/gateways/istio-egress \
-n istio-system -n istio-system
{{< /text >}} {{< /text >}}
@ -94,7 +94,7 @@ to the missing `istio-token` volume.
1. Ensure all Kubernetes pods in `istio-system` namespace are deployed and have a 1. Ensure all Kubernetes pods in `istio-system` namespace are deployed and have a
`STATUS` of `Running`: `STATUS` of `Running`:
{{< text bash >}} {{< text syntax=bash snip_id=none >}}
$ kubectl get pods -n istio-system $ kubectl get pods -n istio-system
{{< /text >}} {{< /text >}}
@ -122,14 +122,14 @@ validation while unstructured Helm values do not.
Before upgrading Istio in your cluster, we recommend creating a backup of your Before upgrading Istio in your cluster, we recommend creating a backup of your
custom configurations, and restoring it from backup if necessary: custom configurations, and restoring it from backup if necessary:
{{< text bash >}} {{< text syntax=bash snip_id=create_backup >}}
$ kubectl get istio-io --all-namespaces -oyaml > $HOME/istio_resource_backup.yaml $ kubectl get istio-io --all-namespaces -oyaml > "$HOME"/istio_resource_backup.yaml
{{< /text >}} {{< /text >}}
You can restore your custom configuration like this: You can restore your custom configuration like this:
{{< text bash >}} {{< text syntax=bash snip_id=restore_backup >}}
$ kubectl apply -f $HOME/istio_resource_backup.yaml $ kubectl apply -f "$HOME"/istio_resource_backup.yaml
{{< /text >}} {{< /text >}}
### Migrating from non-Helm installations ### Migrating from non-Helm installations
@ -168,7 +168,7 @@ gateways is [actively in development](/docs/setup/upgrade/gateways/) and is cons
1. Install a canary version of the Istio discovery chart by setting the revision 1. Install a canary version of the Istio discovery chart by setting the revision
value: value:
{{< text bash >}} {{< text syntax=bash snip_id=canary_install_discovery >}}
$ helm install istiod-canary manifests/charts/istio-control/istio-discovery \ $ helm install istiod-canary manifests/charts/istio-control/istio-discovery \
--set revision=canary \ --set revision=canary \
-n istio-system -n istio-system
@ -176,7 +176,7 @@ gateways is [actively in development](/docs/setup/upgrade/gateways/) and is cons
1. Verify that you have two versions of `istiod` installed in your cluster: 1. Verify that you have two versions of `istiod` installed in your cluster:
{{< text bash >}} {{< text syntax=bash snip_id=none >}}
$ kubectl get pods -l app=istiod -L istio.io/rev -n istio-system $ kubectl get pods -l app=istiod -L istio.io/rev -n istio-system
NAME READY STATUS RESTARTS AGE REV NAME READY STATUS RESTARTS AGE REV
istiod-5649c48ddc-dlkh8 1/1 Running 0 71m default istiod-5649c48ddc-dlkh8 1/1 Running 0 71m default
@ -189,7 +189,7 @@ gateways is [actively in development](/docs/setup/upgrade/gateways/) and is cons
1. Once you have verified and migrated your workloads to use the canary control 1. Once you have verified and migrated your workloads to use the canary control
plane, you can uninstall your old control plane: plane, you can uninstall your old control plane:
{{< text bash >}} {{< text syntax=bash snip_id=none >}}
$ helm delete istiod -n istio-system $ helm delete istiod -n istio-system
{{< /text >}} {{< /text >}}
@ -207,13 +207,13 @@ preserve your custom configuration during Helm upgrades.
1. Upgrade the Istio base chart: 1. Upgrade the Istio base chart:
{{< text bash >}} {{< text syntax=bash snip_id=canary_upgrade_base >}}
$ helm upgrade istio-base manifests/charts/base -n istio-system $ helm upgrade istio-base manifests/charts/base -n istio-system
{{< /text >}} {{< /text >}}
1. Upgrade the Istio discovery chart: 1. Upgrade the Istio discovery chart:
{{< text bash >}} {{< text syntax=bash snip_id=canary_upgrade_discovery >}}
$ helm upgrade istiod manifests/charts/istio-control/istio-discovery \ $ helm upgrade istiod manifests/charts/istio-control/istio-discovery \
-n istio-system -n istio-system
{{< /text >}} {{< /text >}}
@ -221,7 +221,7 @@ preserve your custom configuration during Helm upgrades.
1. (Optional) Upgrade the Istio ingress or egress gateway charts if installed in 1. (Optional) Upgrade the Istio ingress or egress gateway charts if installed in
your cluster: your cluster:
{{< text bash >}} {{< text syntax=bash snip_id=canary_upgrade_gateways >}}
$ helm upgrade istio-ingress manifests/charts/gateways/istio-ingress \ $ helm upgrade istio-ingress manifests/charts/gateways/istio-ingress \
-n istio-system -n istio-system
$ helm upgrade istio-egress manifests/charts/gateways/istio-egress \ $ helm upgrade istio-egress manifests/charts/gateways/istio-egress \
@ -235,20 +235,25 @@ installed above.
1. List all the Istio charts installed in `istio-system` namespace: 1. List all the Istio charts installed in `istio-system` namespace:
{{< text bash >}} {{< text syntax=bash snip_id=helm_ls >}}
$ helm ls -n istio-system $ helm ls -n istio-system
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
istio-base istio-system 1 ... ... ... ... deployed base-1.9.0
istio-egress istio-system 1 ... ... ... ... deployed istio-egress-1.9.0
istio-ingress istio-system 1 ... ... ... ... deployed istio-ingress-1.9.0
istiod istio-system 1 ... ... ... ... deployed istio-discovery-1.9.0
{{< /text >}} {{< /text >}}
1. (Optional) Delete Istio ingress/egress chart: 1. (Optional) Delete Istio ingress/egress chart:
{{< text bash >}} {{< text syntax=bash snip_id=delete_delete_gateway_charts >}}
$ helm delete istio-egress -n istio-system $ helm delete istio-egress -n istio-system
$ helm delete istio-ingress -n istio-system $ helm delete istio-ingress -n istio-system
{{< /text >}} {{< /text >}}
1. Delete Istio discovery chart: 1. Delete Istio discovery chart:
{{< text bash >}} {{< text syntax=bash snip_id=helm_delete_discovery_chart >}}
$ helm delete istiod -n istio-system $ helm delete istiod -n istio-system
{{< /text >}} {{< /text >}}
@ -259,13 +264,13 @@ installed above.
Resource Definitions (CRDs) installed via the chart. Resource Definitions (CRDs) installed via the chart.
{{< /warning >}} {{< /warning >}}
{{< text bash >}} {{< text syntax=bash snip_id=helm_delete_base_chart >}}
$ helm delete istio-base -n istio-system $ helm delete istio-base -n istio-system
{{< /text >}} {{< /text >}}
1. Delete the `istio-system` namespace: 1. Delete the `istio-system` namespace:
{{< text bash >}} {{< text syntax=bash snip_id=delete_istio_system_namespace >}}
$ kubectl delete namespace istio-system $ kubectl delete namespace istio-system
{{< /text >}} {{< /text >}}
@ -274,7 +279,7 @@ installed above.
Deleting CRDs permanently removes any Istio resources you have created in your Deleting CRDs permanently removes any Istio resources you have created in your
cluster. To permanently delete Istio CRDs installed in your cluster: cluster. To permanently delete Istio CRDs installed in your cluster:
{{< text bash >}} {{< text syntax=bash snip_id=delete_crds >}}
$ kubectl get crd | grep --color=never 'istio.io' | awk '{print $1}' \ $ kubectl get crd | grep --color=never 'istio.io' | awk '{print $1}' \
| xargs -n1 kubectl delete crd | xargs -n1 kubectl delete crd
{{< /text >}} {{< /text >}}

View File

@ -0,0 +1,108 @@
#!/bin/bash
# shellcheck disable=SC2034,SC2153,SC2155,SC2164
# Copyright Istio Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
####################################################################################################
# WARNING: THIS IS AN AUTO-GENERATED FILE, DO NOT EDIT. PLEASE MODIFY THE ORIGINAL MARKDOWN FILE:
# docs/setup/install/helm/index.md
####################################################################################################
snip_create_istio_system_namespace() {
kubectl create namespace istio-system
}
snip_install_base() {
helm install istio-base manifests/charts/base -n istio-system
}
snip_install_discovery() {
helm install istiod manifests/charts/istio-control/istio-discovery \
-n istio-system
}
snip_install_ingressgateway() {
helm install istio-ingress manifests/charts/gateways/istio-ingress \
-n istio-system
}
snip_install_egressgateway() {
helm install istio-egress manifests/charts/gateways/istio-egress \
-n istio-system
}
snip_create_backup() {
kubectl get istio-io --all-namespaces -oyaml > "$HOME"/istio_resource_backup.yaml
}
snip_restore_backup() {
kubectl apply -f "$HOME"/istio_resource_backup.yaml
}
snip_canary_install_discovery() {
helm install istiod-canary manifests/charts/istio-control/istio-discovery \
--set revision=canary \
-n istio-system
}
snip_canary_upgrade_base() {
helm upgrade istio-base manifests/charts/base -n istio-system
}
snip_canary_upgrade_discovery() {
helm upgrade istiod manifests/charts/istio-control/istio-discovery \
-n istio-system
}
snip_canary_upgrade_gateways() {
helm upgrade istio-ingress manifests/charts/gateways/istio-ingress \
-n istio-system
helm upgrade istio-egress manifests/charts/gateways/istio-egress \
-n istio-system
}
snip_helm_ls() {
helm ls -n istio-system
}
! read -r -d '' snip_helm_ls_out <<\ENDSNIP
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
istio-base istio-system 1 ... ... ... ... deployed base-1.9.0
istio-egress istio-system 1 ... ... ... ... deployed istio-egress-1.9.0
istio-ingress istio-system 1 ... ... ... ... deployed istio-ingress-1.9.0
istiod istio-system 1 ... ... ... ... deployed istio-discovery-1.9.0
ENDSNIP
snip_delete_delete_gateway_charts() {
helm delete istio-egress -n istio-system
helm delete istio-ingress -n istio-system
}
snip_helm_delete_discovery_chart() {
helm delete istiod -n istio-system
}
snip_helm_delete_base_chart() {
helm delete istio-base -n istio-system
}
snip_delete_istio_system_namespace() {
kubectl delete namespace istio-system
}
snip_delete_crds() {
kubectl get crd | grep --color=never 'istio.io' | awk '{print $1}' \
| xargs -n1 kubectl delete crd
}

View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -e
set -u
set -o pipefail
# @setup profile=none
snip_create_istio_system_namespace
snip_install_base
snip_install_discovery
_wait_for_deployment istio-system istiod
snip_install_ingressgateway
_wait_for_deployment istio-system istio-ingressgateway
snip_install_egressgateway
_wait_for_deployment istio-system istio-egressgateway
# shellcheck disable=SC2154
_verify_like snip_helm_ls "$snip_helm_ls_out"
# @cleanup
snip_delete_crds
helm delete -n istio-system istio-egressgateway
helm delete -n istio-system istio-ingressgateway
helm delete -n istio-system istiod
helm delete -n istio-system istio-base
kubectl delete ns istio-system