This documentation is for WSO2 Microgateway 3.0.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  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.

    Info

    The latter mentioned instructions uses the developer first approach. However, if you wish to work with APIs that you have published in WSO2 API Manager, you can either import a single API or you can import the APIs as a group.

  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.

    Code Block
    [kubernetes]
      [kubernetes.kubernetesDeployment]
        enable = true
        #name = ''
        #labels = ''
        #replicas = ''
        #enableLiveness = ''
        #initialDelaySeconds = ''
        #periodSeconds = ''
        #livenessPort = ''
        #imagePullPolicy = ''
        #image = ''
        #env = ''
        #buildImage = ''
        #copyFiles = ''
        #dockerHost = ''
        #dockerCertPath = ''
        #push = ''
        #username = ''
        #password = ''
        baseImage = 'wso2/wso2micro-gw:latest3.0.2'
        #singleYAML = ''
      [kubernetes.kubernetesService]
        enable = true
        #name = ''
        #labels = ''
        serviceType = 'NodePort'
        #port = ''
      [kubernetes.kubernetesConfigMap]
        enable = true
        ballerinaConf = '<MICROGW_TOOLKIT_HOME>/resources/conf/micro-gw.conf'
        #[[kubernetes.kubernetesConfigMap.configMaps]]
        #    name = ''
        #    mountPath = ''
        #    readOnly = false
        #    data = ['']
    Note

    Make sure to specify the complete path for the ballerinaConf, by replacing the <MICROGW_TOOLKIT_HOME> placeholder with the full path.
    Example:
    home/users/wso2am-micro-gw-toolkit-3.x.x/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. 

    Code Block
    titleFormat
    micro-gw build <project_name> --deployment-config deployment.toml
    Code Block
    titleExample
    micro-gw build k8s_project --deployment-config deployment.toml
    

    This generates the following Kubernetes resources.

    ├── k8s_project

    │   └── docker

    │       └── Dockerfile

    ├── k8s_project_config_map.yaml

    ├── k8s_project_deployment.yaml

    └── k8s_project_svc.yaml

    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.


    Info

    For more options on deploying the Docker image in a Kubernetes environment, see the Deployment related FAQs.


    1. Save the Docker image to a tar file.

      Code Block
      titleFormat
      docker save <MGW-project-name>:latest > <Docker-image-name>.tar
      Code Block
      titleExample
      docker save k8s_project:latest > image.tar
    2. SCP the image to the Kubernetes nodes. 

      Code Block
      titleFormat
      scp -i <identity-file> image.tar [email protected]<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.

        Note

        When using minikube, the username is docker and you can find the IP address by using the minikube ip command.

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

      Code Block
      titleFormat
      docker load < [Docker-image-name].tar
      Code Block
      titleExample
      docker load < image.tar

...