Incapio - Blog Posts © 2022 by Incapio is licensed under CC BY-SA 4.0 

Install Portainer on Google Kubernetes Engine | GCP

Updated: Jan 28

Prerequisites:

You will need the following items to complete this tutorial.

  • A Google Kubernetes Engine cluster with minimum nodes.

  • Portainer Business Edition (BE) - License (Get 5 Free Nodes)

Step - 1. Create a Kubernetes Cluster.

  • In the Google cloud console, navigate to the Kubernetes engine.

  • In the Kubernetes engine menu, click on clusters.

  • In the Kubernetes cluster interface, click on create. (To create a Kubernetes cluster, We have two ways Standard or Autopilot. Standard: You handle the cluster's underlying infrastructure, which gives you control over node configuration. Autopilot: GKE handles the cluster's core infrastructure, including nodes and node pools, on autopilot, providing you with an optimal cluster with a hands-off experience.)

Google Kubernetes Engine Cluster, create, GKE standard, GKE autopilot
GKE Create Cluster Interface
  • In the create cluster interface, click on configure on the right side of the GKE standard.

  • In the cluster basics interface, type and cluster name. For instance, portainer-integration

GKE Cluster, name, zone, node location
Cluster Basic Configuration

.

  • Select the zone or region you prefer to create the cluster in the cluster basics interface and specify the default node location.

  • Please Note: Increase availability by selecting more than one zone.

  • In the control plane version section, choose a release channel. (According to the portainer website currently, portainer BE supports these kubernetes versions (1.19.11 1.20.7 1.21 1.22) and these versions are tested and functional for the production environment.)

  • To learn more about the stable and release channels, visit the link here.

  • In the release channel section, select the release channel type and version. For instance, type=stable channel and version=1.20.11-gke.1300(default).

NODE POOLS

Node pool, nodes, auto-scaling, minimum and maximum nodes
Node Pool Configuration
  • To create a kubernetes cluster interface, click on the default-pool option under the node pools section on the left side.

  • Type the node pool name and size(how many nodes for the zone) and enable auto-scaling; specify(Maximum nodes per zone).

nodes, ubuntu, containerd, machine family, series,
Nodes and Image Type Configuration
  • In the default-pool interface, select the nodes.

  • Select the image type to "Ubuntu with Containerd" in the node interface. To learn more about images types, visit the link here.

  • Select the series to E2 and machine type to e2-small(2vCPU, 2 GB memory) in the machine configuration section. Also, specify the boot disk size.

  • To create a Kubernetes cluster interface, click on the Automation under the cluster and enable vertical pod auto-scaling and node auto-provisioning and specify the resource type, minimum and maximum.

  • To create a Kubernetes cluster interface, click on the networking under the cluster and enable NodeLocal DNS cache and HTTP load balancing.

  • Finally, click on create to deploy a new cluster.

Connect to the cluster.

Portainer, cluster, install, setup, location, nodes, CPU, memory
Clusters Interface
  • Once the cluster setup is completed, click on the name to verify the details.

  • Then, click on connect to launch a cloud shell in the cluster interface.

  • To connect to the cluster window, click on the "Run in cloud shell" to connect the cluster via the command line and authorize the access.

$ gcloud container clusters get-credentials portainer-integration --zone us-east1-b --project elegant-canto-331917
Fetching cluster endpoint and auth data.
kubeconfig entry generated for portainer-integration.

Step - 2. Install Portainer on your self-managed infrastructure using Kubernetes.


Storage Class
  • Because Portainer requires data persistence, it must have at least one StorageClass accessible for usage.

  • Run the following command on your cluster to see if you have a default StorageClass:

$ kubectl get sc
  • Output:

NAME                 PROVISIONER             RECLAIMPOLICY        
premium-rwo          pd.csi.storage.gke.io   Delete          
standard (default)   kubernetes.io/gce-pd    Delete          
standard-rwo         pd.csi.storage.gke.io   Delete
  • Then search for StorageClasses that have (default) after their names:

  • To make a StorageClass the default, use the following syntax:

kubectl patch storageclass <storage-class-name> -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  • Example:

kubectl patch storageclass standard -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
  • <storage-class-name> should be replaced with the name of your StorageClass.

  • Output:

storageclass.storage.k8s.io/standard patched (no change)

Step - 3. Install portainer using Helm chart.

  • Helm charts are used to deploy Portainer on a Kubernetes cluster.

  • To begin, use the following commands to add the Portainer Helm repository:

helm repo add portainer https://portainer.github.io/k8s/
helm repo update
  • Output:

$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "portainer" chart repository
...Successfully got an update from the "bitnami" chart repository
Update Complete. ⎈Happy Helming!
  • Once the update is complete, you may begin installing using the load balancer.

  • Portainer will be available on port 9443 for HTTPS at an associated Load Balancer IP with the following command:

helm install --create-namespace -n portainer portainer portainer/portainer \
    --set service.type=LoadBalancer \
    --set enterpriseEdition.enabled=true \
    --set tls.force=true
  • Output:

$ helm install --create-namespace -n portainer portainer portainer/portainer \>     --set service.type=LoadBalancer \
>     --set enterpriseEdition.enabled=true \
>     --set tls.force=trueNAME: portainer
LAST DEPLOYED: Mon Dec 27 17:45:11 2021
NAMESPACE: portainer
STATUS: deployed
REVISION: 1
NOTES:
Get the application URL by running these commands:
     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get --namespace portainer svc -w portainer'
  export SERVICE_IP=$(kubectl get svc --namespace portainer portainer --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
  echo http://$SERVICE_IP:9443
  • Check the status by running the following command.

$ kubectl get --namespace portainer svc -w portainer
  • Output:

NAME        TYPE           CLUSTER-IP    EXTERNAL-IP    PORT(S)                         AGE
portainer   LoadBalancer   10.88.14.39   34.73.73.241   9443:31080/TCP,8000:31742/TCP   63s

Step - 4 Logging In

  • You may now log into your Portainer Server instance when the installation is complete. Navigate to the following URL in a web browser:

https://<loadbalancer IP>:9443/
  • Replace <loadbalancer IP> with the External IP address

Conclusion

Here are some recommended tips and tricks.


131 views0 comments

Do you need assistance? Visit Forum to join the conversation.