Microk8s install helm3

It was like this when we used the official order . But using official sources , The network is extremely unstable . The following situation appears . The solution is to change to domestic sources .

microk8s enable helm3

curl: (56) GnuTLS recv error (-54): Error in the pull function.

adopt ps Command to view the work of the process

You can see the use of microk8s enable helm3 When , The command executed and the directory of work . Use this to determine the working data directory .

Get into action When I looked at the catalog, I saw enable.helm3.sh Script for .

[email protected]:/snap/microk8s/2035/actions# ls
common                  disable.knative.sh         enable.gpu.sh             enable.rbac.sh
coredns.yaml            disable.kubeflow.sh        enable.ha-cluster.sh      enable.registry.sh
dashboard.yaml          disable.linkerd.sh         enable.helm.sh            enable.storage.sh
disable.ambassador.sh   disable.metallb.sh         enable.helm3.sh           enable.traefik.sh
disable.cilium.sh       disable.metrics-server.sh  enable.host-access.sh     fluentd
disable.dashboard.sh    disable.multus.sh          enable.ingress.sh         gpu.yaml
disable.dns.sh          disable.portainer.sh       enable.istio.sh           ingress.yaml
disable.fluentd.sh      disable.prometheus.sh      enable.jaeger.sh          jaeger
disable.gpu.sh          disable.rbac.sh            enable.juju.sh            knative
disable.ha-cluster.sh   disable.registry.sh        enable.keda.sh            metallb.yaml
disable.helm.sh         disable.storage.sh         enable.knative.sh         metrics-server.yaml
disable.helm3.sh        disable.traefik.sh         enable.kubeflow.sh        multus.yaml
disable.host-access.sh  dns.yaml                   enable.linkerd.sh         prometheus
disable.ingress.sh      enable.ambassador.sh       enable.metallb.sh         registry-help.yaml
disable.istio.sh        enable.cilium.sh           enable.metrics-server.sh  registry.yaml
disable.jaeger.sh       enable.dashboard.sh        enable.multus.sh          storage.yaml
disable.juju.sh         enable.dns.sh              enable.portainer.sh       traefik.yaml
disable.keda.sh         enable.fluentd.sh          enable.prometheus.sh

View the script

[email protected]:/snap/microk8s/2035/actions# cat enable.helm3.sh 
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
CA_CERT=/snap/core/current/etc/ssl/certs/ca-certificates.crt
echo "Enabling Helm 3"
if [ ! -f "${SNAP_DATA}/bin/helm3" ]
then
  #  Here is the official source address , It's because it causes the download to time out .
  SOURCE_URI="https://get.helm.sh"
  HELM_VERSION="v3.0.2"
  echo "Fetching helm version $HELM_VERSION."
  run_with_sudo mkdir -p "${SNAP_DATA}/tmp/helm"
  (cd "${SNAP_DATA}/tmp/helm"
  run_with_sudo "${SNAP}/usr/bin/curl" --cacert $CA_CERT -L $SOURCE_URI/helm-$HELM_VERSION-linux-$(arch).tar.gz -o "$SNAP_DATA/tmp/helm/helm.tar.gz"
  run_with_sudo gzip -f -d "$SNAP_DATA/tmp/helm/helm.tar.gz"
  run_with_sudo tar -xf "$SNAP_DATA/tmp/helm/helm.tar")
  run_with_sudo mkdir -p "$SNAP_DATA/bin/"
  run_with_sudo mv "$SNAP_DATA/tmp/helm/linux-$(arch)/helm" "$SNAP_DATA/bin/helm3"
  run_with_sudo chmod +x "$SNAP_DATA/bin/"
  run_with_sudo chmod +x "$SNAP_DATA/bin/helm3"
  run_with_sudo rm -rf "$SNAP_DATA/tmp/helm"
fi
echo "Helm 3 is enabled"
[email protected]:/snap/microk8s/2035/actions#

After changing it directly, save and exit , Report errors .

File system read only , That's because it's a loopback address mounted locally by the installation program. It's mounted read-only , The attempt to mount in a read-write manner failed .

Then copy the script , Changes are executed separately .

[email protected]:~# cat /tmp/enable.helm3.sh 
#!/usr/bin/env bash
set -e
#  Manually added directory variables
SNAP=/snap/microk8s/2035
SNAP_DATA=/var/snap/microk8s/2035
source $SNAP/actions/common/utils.sh
CA_CERT=/snap/core/current/etc/ssl/certs/ca-certificates.crt
echo "Enabling Helm 3"
if [ ! -f "${SNAP_DATA}/bin/helm3" ]
then
  #  Change to Huawei's source
  SOURCE_URI="https://mirrors.huaweicloud.com/helm/v3.0.2/"
  HELM_VERSION="v3.0.2"
  echo "Fetching helm version $HELM_VERSION."
  run_with_sudo mkdir -p "${SNAP_DATA}/tmp/helm"
  (cd "${SNAP_DATA}/tmp/helm"
  # $(arch) Changed to amd64
  run_with_sudo "${SNAP}/usr/bin/curl" --cacert $CA_CERT -L $SOURCE_URI/helm-$HELM_VERSION-linux-amd64.tar.gz -o "$SNAP_DATA/tmp/helm/helm.tar.gz"
  run_with_sudo gzip -f -d "$SNAP_DATA/tmp/helm/helm.tar.gz"
  run_with_sudo tar -xf "$SNAP_DATA/tmp/helm/helm.tar")
  run_with_sudo mkdir -p "$SNAP_DATA/bin/"
  run_with_sudo mv "$SNAP_DATA/tmp/helm/linux-amd64/helm" "$SNAP_DATA/bin/helm3"
  run_with_sudo chmod +x "$SNAP_DATA/bin/"
  run_with_sudo chmod +x "$SNAP_DATA/bin/helm3"
  run_with_sudo rm -rf "$SNAP_DATA/tmp/helm"
fi
echo "Helm 3 is enabled"
#  perform
[email protected]:/tmp# ./enable.helm

View results