Build a container image

Using the migration artifacts, build a container image for the migrated app that you can then deploy to your target cluster. You can build the container image using build.sh or Skaffold.

Skaffold allows you to build and deploy in the same command, and is typically easier to use. To build using Skaffold, see Build and deploy multiple images using Skaffold.

To use build.sh to build the container:

  1. Build the app container using the build script.

    chmod +x ./build.sh
    PROJECT_ID=PROJECT_ID TAG_NAME=TAG_NAME ./build.sh TARGET
    

    For TARGET, use openliberty or twas.

    On openliberty, if sensitive data is collected, liberty-secrets.yaml is generated. You need to apply the liberty-secrets.yaml prior to applying deployment_spec.yaml

    kubectl apply -f liberty-secrets.yaml
    
  2. Optionally set the service type in deployment_spec.yaml.

    By default, Migrate to Containers sets the service type to ClusterIP, which makes the service available only to the pods in the deployment cluster.

    If you want to be able to access the service externally, set the service type to LoadBalancer, or to any other type required by your deployment. For example:

    apiVersion: v1
    kind: Service
    …
    spec:
      …
      type: LoadBalancer

You can now deploy the app container.

You can also use skaffold to build all applications:

  1. Install skaffold

    # For Linux x86_64 (amd64)
    curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \
    sudo install skaffold /usr/local/bin/
    
  2. Run skaffold build on the download artifacts and skaffold run. And then check that the containers have been deployed.

    skaffold build --build-concurrency=1 --profile cloudbuild --default-repo=eu.gcr.io/${PROJECT_ID} --file-output artifacts.json
    
    skaffold render  --namespace=default --build-artifacts=artifacts.json | tee full_deployment.yaml
    

Next steps

Deploy a workload