Kubernetes on DigitalOcean

Run Kubernetes Command via Local Computer

Prepare Environment

sudo snap install kubectl --classic
sudo snap install helm --classic

Download Kubernetes config file from DigitalOcean and export it into KUBECONFIG.

export KUBECONFIG=/www/wwwroot/k8s/kube-config.yaml

Install Cert-Manager

Rancher requires Cert-Manager for managing certificates. Add the Cert-Manager Helm repository:

helm repo add jetstack https://charts.jetstack.io
helm repo update

Running result:

Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "jetstack" chart repository
Update Complete. ⎈Happy Helming!⎈

Install Cert-Manager in your cluster:

kubectl create namespace cert-manager
helm install cert-manager jetstack/cert-manager \
  --namespace cert-manager \
  --version v1.12.3 \
  --set installCRDs=true

Running result:

NAME: cert-manager
LAST DEPLOYED: Sun Dec  1 10:06:17 2024
NAMESPACE: cert-manager
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
cert-manager v1.12.3 has been deployed successfully!

In order to begin issuing certificates, you will need to set up a ClusterIssuer
or Issuer resource (for example, by creating a 'letsencrypt-staging' issuer).

More information on the different types of issuers and how to configure them
can be found in our documentation:

https://cert-manager.io/docs/configuration/

For information on how to configure cert-manager to automatically provision
Certificates for Ingress resources, take a look at the `ingress-shim`
documentation:

https://cert-manager.io/docs/usage/ingress/

Verify the Cert-Manager pods are running:

kubectl get pods --namespace cert-manager

Add the Rancher Helm Chart Repository

Add Rancher's Helm repository:

helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
helm repo update

Install Rancher

Choose a namespace for Rancher (commonly cattle-system):

kubectl create namespace cattle-system

Install Rancher with Helm:

helm install rancher rancher-latest/rancher \
  --namespace cattle-system \
  --set hostname=<YOUR_RANCHER_DOMAIN>

Setup Kubeconfig on a Droplet

Download Kubeconfig

  1. Open from menu Manage > Kubernetes.
  2. Click your target Kubernetes cluster.
  3. From Overview, click Download Config File.

k8s-download-kubeconfig.PNG

Upload Kubeconfig via SSH

Setup Kubeconfig

Run this following commands:

mkdir -p ~/.kube
cp ~/k8s/kubeconfig.yaml ~/.kube/config