Skip to content

Step by Step Guide#

In this guide we will deploy an application with tilt and namespace in remote OpenShift cluster

  1. Clone this sample repo Nordmart-review

  2. Install following tools:

    Required for local development:

    • Tilt v0.22.11 or above
    • Docker 20.10.8 or above
    • Helm 3 or above
    • oc binaries

    Required by this application:

    • Java 11
    • Maven 3
  3. You should have a namespace in remote/local cluster; If you are in SAAP then enable sandbox namespace/project/environment for your tenant; you can read more here

  4. Login to cluster

    Login into OpenShift and then copy login command

    Copy login command

    Then click Display Token

    Display Token

    Then copy the login token

    Copy login token

    And then run this command in the terminal

    oc login --token=<TOKEN> --server=<SERVER>
    
  5. Switch project to sandbox namespace/project/environment

    oc project <MY-SANDBOX>
    
  6. Login to OpenShift internal docker registry

    First get the OpenShift internal docker registry URL and set in HOST variable name

    HOST=image-registry-openshift-image-registry.apps.[CLUSTER-NAME].[CLUSTER-ID].kubeapp.cloud
    

    NOTE: Ask Customer Admin or Cluster Admin to provide you the OpenShift internal registry route

    Then login into docker registry with following command:

    docker login -u $(oc whoami) -p $(oc whoami -t) $HOST
    

    If you get this error x509: certificate signed by unknown authority then you need to update your /etc/docker/daemon.json file and add the insecure registry

    {
        "insecure-registries" : [ "HOST" ]
    }
    
  7. (Optional) Add Helm chart repos

    If you reference Helm charts from private registry then you first need to add it

    cd deploy
    
    # Helm credentials can be found in Vault or in a secret in build namespace
    helm repo add stakater-nexus <private repo URL> --username helm-user-name --password ********;
    
    cd ..
    
  8. Update Helm dependencies

    cd deploy
    
    helm dependency update
    
    cd ..
    
  9. Go through the Tiltfile of the application

  10. Check the local_resource section in the Tiltfile

  11. Create tilt_options.json file

    Remove .template from the file named tilt_options.json.template

    Create tilt options JSON

    And then fill up all three things

    1. namespace: your sandbox environment name
    2. default_registry: the OpenShift internal registry route (you have set in step # 6 in HOST above) and then add your namespace name after /
    3. allow_k8s_contexts: given you are logged in the cluster; then run oc config current-context to get the value for allow_k8s_contexts

      e.g.

      {
          "namespace": "tilt-username-sandbox",
          "default_registry": "image-registry-openshift-image-registry.apps.[CLUSTER-NAME].[CLUSTER-ID].kubeapp.cloud/tilt-username-sandbox",
          "allow_k8s_contexts": "tilt-username-sandbox/api-[CLUSTER-NAME]-[CLUSTER-ID]-kubeapp-cloud:6443/user@email.com"
      }
      
  12. Go through the .gitigore and check tilt and Helm specific ignores

    # Tilt
    tilt_options.json
    tilt_modules/
    
    # Helm
    /deploy/charts
    
  13. Go through .tiltignore

    **/charts
    **/tmpcharts
    
  14. Go through values-local.yaml in a tilt folder in base application directory.

    values-local.yaml should contain the following content. Make sure that replica count should always be 1.

    application:
    
      deployment:
        imagePullSecrets: null
    
        # Tilt live update only supports one replica
        replicas: 1
    
        image:
          tag: null
    
  15. Validate this application is not running already

    sandbox namespace

  16. Run tilt up at base directory

    tilt up

    Open the tilt browser; just hit the space

    tilt browser

    If everything is green then the application will be deployed in the cluster

    sandbox namespace

    Press space key to view the progress in Tilt web UI. The application should be running in the namespace used in tilt_options.json file.

  17. Lets browse through some reviews. Go to routes:

    find route

    Click on the review route:

    review-route

    In the end of the route add /api/review/329199

    Review the JSON output:

    product review

  18. Lets make one change; we will update the first review text to "Tilt Demo"

    update review service

    Switch back to tilt browser and you will see it has started picking up changes

    tilt pick up change

    Within few seconds the change will be deployed; and you can refresh the route to see the change

    updated review

    Awesome! you made it

  19. Run tilt down to delete the application and related configuration from the namespace