Install on Kubernetes
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Install on Kubernetes

 

Follow the instructions below to deploy WSO2 API Microgateway in Kubernetes.

Step 1 - Follow the installation prerequisites

Make sure to do the following:

  1. Carry  out the installation prerequisites for WSO2 API Microgateway Toolkit.

  2. Install and setup kubectl in your client machine.

  3. Setup a Kubernetes cluster.

  4. Make sure that kubectl points to your Kubernetes cluster.

Step 2 - Create a Microgateway project

  1. Navigate to a preferred workspace folder using the command line to set the location that is used to store the Microgateway project.

  2. Create a project.
    Let's create a project named k8s_project  by running the following command. This will create the folder structure for the artifacts to be included.

    Format

    micro-gw init <project_name>

    Example

    micro-gw init k8s_project Project 'k8s_project' is initialized successfully.

Step 3 - Build the Microgateway project

  1. Add the API to the project. 

    Navigate to the  /petstore/api_definitions  directory and add the OpenAPI definition(s) to this  directory. Let's use the  Petstore sample OpenAPI definition in this scenario.

  2. Create the input for WSO2 API Microgateway Toolkit.
    Create a deployment.toml file that you will use as the input when creating the microgateway project. This TOML file should contain the relevant deployment configurations as shown below. For more information on each of the above parameters, see deployment.toml for Kubernetes.

    [kubernetes] [kubernetes.kubernetesDeployment] enable = true name = 'k8s' tag = 'v1' #labels = '' replicas = '1' #enableLiveness = '' #initialDelaySeconds = '' #periodSeconds = '' #livenessPort = '' #imagePullPolicy = 'Always' #imagePullSecrets = ['secret1'] #image = '' #env = '' buildImage = true #cmd = 'CMD gateway ${APP} --b7a.config.file=conf/micro-gw.conf --b7a.log.level=DEBUG' #copyFiles = '' #dockerHost = '' #dockerCertPath = '' #push = 'false' #registry = 'index.docker.io/<DOCKER_USERNAME>' #username = '' #password = '' baseImage = 'wso2/wso2micro-gw:3.1.0' [kubernetes.kubernetesDeployment.livenessProbe] enable = true initialDelaySeconds = '20' periodSeconds = '20' [kubernetes.kubernetesDeployment.readinessProbe] enable = true initialDelaySeconds = '30' periodSeconds = '30' [kubernetes.kubernetesServiceHttps] enable = true name = 'httpsService' #labels = '{"": ""}' serviceType = 'NodePort' #port = '' [kubernetes.kubernetesServiceHttp] enable = true name = 'httpService' #labels = '{"": ""}' serviceType = 'NodePort' #port = '' [kubernetes.kubernetesConfigMap] enable = true ballerinaConf = '<MICROGW_TOOLKIT_HOME>/resources/conf/micro-gw.conf'
  3. Build the microgateway project.

    Use your command line tool to navigate to where the project directory ( k8s_project ) was created and execute the following command to build the project. 

    Format

    micro-gw build <project_name> --deployment-config deployment.toml

    Example

    micro-gw build k8s_project --deployment-config deployment.toml

    This generates the following Kubernetes resources.

    ├── k8s_project

    │    └── api_definitions

    │    └── conf

    │    └── extensions

    │    └── grpc_definitions

    │    └── policies.yaml

    │    └── target

    │    │     └── gen

    │    │     │    └── gRPCSrc

    │    │     │    └── src

    │    │     │    └── target

    │    │     │    │    └── balo

    │    │     │    │    └── bin

    │    │     │    │    └── caches

    │    │     │    │    └── docker

    │    │     │    │    │     └── k8s_project

    │    │     │    │    │     │    └── Dockerfile

    │    │     │    │    └── kubernetes

    │    │     │    │    │     └── k8s_project

    │    │     │    │    │     │      └── k8s

    │    │     │    │    │     │      │    └── Chart.yaml

    │    │     │    │    │     │      │    └── templates

    │    │     │    │    │     │      │    │      └── k8s_project.yaml

    │    │     │    │    │     │      └── k8s_project.yaml

    │    └── k8s_project.jar

    The Docker image to be deployed in Kubernetes is created in your local registry. You can find the image k8s_project:latest when you execute the Docker images command.

    Step 4 - Deploy the Docker image in a Kubernetes environment

    Let's SCP the image to the Kubernetes nodes to deploy the Docker image in a K8s environment.

     

     

    1. Save the Docker image to a tar file.

      Format

      docker save <MGW-project-name>:latest > <Docker-image-name>.tar

      Example

      docker save k8s_project:latest > image.tar
    2. SCP the image to the Kubernetes nodes. 

      Format

      scp -i <identity-file> image.tar username@<K8s_NODE_IP>:
      • Identity file - This refers to the public key of the Kubernetes node. For example you can get a google_compute_engine.pub for GCE. You have to scp the Docker image for each and every Kubernetes node.

    3. Load the Docker image in the Kubernetes nodes.
      You need to execute the following command in the Kubernetes nodes. 

      Format

      docker load < [Docker-image-name].tar

      Example

      docker load < image.tar
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.