Deploy Agrolly-Web to a Kubernetes cluster on IBM Cloud. Here the Kuber
- Register for an IBM Cloud account.
- Setup the CLIs
- Setup a Virtual Private Cloud (VPC) in IBM Cloud
- Setup a Kubernetes VPC Gen 2 cluster on the IBM Cloud
-
The Kubernetes cluster is created in a VPC Gen 2 cluster. Make sure a VPC is created by following VPC setup guides.
-
Create a Kubernetes cluster for the VPC created in the previous step,
- In the IBM Cloud Catalog, select Kubernetes Service. A cluster configuration page opens.
- Give your cluster a unique name, example:
agrolly-web
. - From the Pricing plan dropdown, select the Standard cluster option.
- In Orchestration service section, select the Kubernetes option.
- In Infrastructure section, select the VPC option. Choose the VPC verified in step 1.
- Select the Resource group for your cluster.
- From the Worker pool section,
- Configure the flavor and number worker nodes required for the cluster.
- Enter a unique name for the worker pool.
- From Master service endpoint, select Both private & public endpoints option.
- In Resource details section,
- Enter a unique cluster name, example:
agrolly-k8-cluster
- Optionally enter tags, example: env:prod, version-1
- Enter a unique cluster name, example:
To learn more about creating VPC Gen 2 cluster click link.
-
While your cluster is provisioning, set up your local workstation with the client tools.
-
Download and install a few CLI tools and the Kubernetes Service plug-in.
curl -sL https://ibm.biz/idt-installer | bash
-
Log in to your IBM Cloud account. Include the --sso option if you have a federated ID.
ibmcloud login -a cloud.ibm.com -r <region> -g <resource-group>
-
Set the Kubernetes context to your cluster for this terminal session. This command will fail if the cluster isn't yet ready.
ibmcloud ks cluster config --cluster <your cluster id>
-
Verify that you can connect to your cluster.
kubectl config current-context
-
Now, you can run
kubectl
commands to manage your cluster on the IBM Cloud. For a full list of commands, see the Kubernetes docs.
-
Build the docker image with
<region>.icr.io/<my_namespace>/<new_image_repo>:<new_tag>
naming convention to later push into IBM Cloud Container Registry
For example:docker build . -t us.icr.io/agrolly-workspace/agrolly-web:v1
-
Update the docker image pushed to Container Registry in
~/Agrolly-Web/deployment.yaml
file.spec: containers: - name: <enter a name for the container> image: <enter container registry image name/tag> imagePullSecrets: - name: all-icr-io
-
Update the Ingress subdomain value, secret name and host value that needs to be routed to cluster service in
~/Agrolly-Web/deployment.yaml
file. The Ingress subdomain value and secret name can be obtained by executing the commandibmcloud ks cluster get --cluster <cluster_name_or_ID> | grep Ingress
.apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: agrolly-ingress-resource annotations: kubernetes.io/ingress.class: "public-iks-k8s-nginx" spec: tls: - hosts: - <Enter the Ingress subdomain value here> secretName: <Enter the Ingress secret value here> rules: - host: <Enter host here. Example "agrolly.com" >
-
Deploy Agrolly-Web to Kubernetes by executing command
kubectl apply -f deployment.yaml
-
Enter the host URL in the browser to launch the Agrolly Web App.
NOTE: To do a rolling update any new changes repeat steps 2, 3, 4 and 6.