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

All docs This doc

Versions Compared


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


    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
        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 = ''
        enable = true
        #name = ''
        #labels = ''
        serviceType = 'NodePort'
        #port = ''
        enable = true
        ballerinaConf = '<MICROGW_TOOLKIT_HOME>/resources/conf/micro-gw.conf'
        #    name = ''
        #    mountPath = ''
        #    readOnly = false
        #    data = ['']

    Make sure to specify the complete path for the ballerinaConf, by replacing the <MICROGW_TOOLKIT_HOME> placeholder with the full path.

  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
    micro-gw build <project_name> --deployment-config deployment.toml
    Code Block
    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.


    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
      docker save <MGW-project-name>:latest > <Docker-image-name>.tar
      Code Block
      docker save k8s_project:latest > image.tar
    2. SCP the image to the Kubernetes nodes. 

      Code Block
      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 for GCE. You have to scp the Docker image for each and every Kubernetes node.


        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
      docker load < [Docker-image-name].tar
      Code Block
      docker load < image.tar