# Deploy To CKAN Cloud

# Creating CKAN Portal - Deploying for first time

In order to deploy CKAN portal on our Kubernetes cluster, you will need to first dockerize the CKAN application. For that you will need:

  • Dockerfile to build an image.
  • .env file to keep environment variables for an image.
  • .gitlab-ci.yml to deploy an image to the container registry.

Later, Kubernetes will pull that image and build a portal using it.

We keep those file in private GitLab Repositories.

Create a new project in GitLab:

  • Navigate to https://gitlab.com/viderum
  • Click the “New Project” button on the right
  • Let’s name it cloud-deploy-demo-exercise
    • We use following name convention: cloud-[project-id]
  • Click “Create Project”

You should have an empty repository on https://gitlab.com/viderum/cloud-deploy-demo-exercise. Let’s now add the necessary files.

# Create Dockerfile

Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Usually, all you need is to copy the Dockerfile from the existing project, and modify per your needs. In your GitLab repo:

# Create .env file

Some of the CKAN configuration options can be defined as Environment variables on the server operating system. We keep these variables in the .env file. In your GitLab repo:

# Create .gitlab-ci.yml

.gitlab-ci.yml is responsible for running continuous deployments. It builds the newest image of the portal and pushes it to the Gitlab registry. To create it:

At this point, you should have all 3 files in your repository.

Wait until the GitLab Build is successful.

Green means the build was successful, and our image was deployed to the GitLab Container registry. That means we are ready to create a new instance on the K8 cluster. 🚀

# Create Instance

Now we need to deploy the new image to CKAN Cloud

Wait until the build is successful. Once done, that’s it! Our instance is deployed to the K8 cluster. Finally, let’s create a route for it.

# Create route

In the last step, we need to create the route for your portal, so that it’s publicly accessible.

# Check it is working

That’s It! 🎆 You should now be able to visit https://deploy-demo-exercise.ckan.io and see the live portal.

# Next steps

Redeploy To CKAN Cloud