Skip to content

Latest commit

 

History

History
111 lines (80 loc) · 5.11 KB

KUBERNETES.md

File metadata and controls

111 lines (80 loc) · 5.11 KB

Deployment to Kubernetes

Deploy Agrolly-Web to a Kubernetes cluster on IBM Cloud. Here the Kuber

Pre-requisites

  1. Register for an IBM Cloud account.
  2. Setup the CLIs
  3. Setup a Virtual Private Cloud (VPC) in IBM Cloud
  4. Setup a Kubernetes VPC Gen 2 cluster on the IBM Cloud

Setup a Virtual Private Cloud (VPC) in IBM Cloud

  1. VPC Get Started guide
  2. Create VPC from IBM Cloud console guide

Set up a Kubernetes VPC Gen 2 cluster on the IBM Cloud

  1. The Kubernetes cluster is created in a VPC Gen 2 cluster. Make sure a VPC is created by following VPC setup guides.

  2. 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

    To learn more about creating VPC Gen 2 cluster click link.

  3. 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.

Deploy Agrolly Web App to Kubernetes VPC Gen 2 cluster

  1. Setup IBM Cloud Container Registry

  2. 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

  3. Push Docker image to Container Registry namespace

  4. 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
  5. 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 command ibmcloud 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" >
  6. Deploy Agrolly-Web to Kubernetes by executing command kubectl apply -f deployment.yaml

  7. 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.