CKAN on Kubernetes

CKAN in general

​CKAN is a highly integrated software for creating data portals, and provides tools which make the publication, sharing and usage of data easy. It is a powerful data management system that makes data discoverable. CKAN is open-source and can be tailored to individual needs. It offers over 200+ available extra functionalities and extensions, that can easily be added to any data portal. CKAN itself includes: data publishing, visualization tools, accessing data through an API, rich search experience, integration with third-party services, data harvesting from external sources and much more.​

Kubernetes in general

​Kubernetes is an open-source container-orchestration system for automating computer application deployment, scaling, and management. It was originally designed by Google and is now maintained by the Cloud Native Computing Foundation. It is the de facto standard for cloud management with all the endless practicalities that it provides and it is the type of deployment for CKAN instances that we recommend.​

How they work together

Prerequisites

  1. kubectl

    There are many ways to install kubectl. One of them is through these commands:

    curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
    
    chmod +x ./kubectl
    
    sudo mv ./kubectl /usr/local/bin/kubectl
    
    kubectl version --client
    

​ 2. Helm

There are various other ways to install Helm 3 depending on your choice as well. One quick way to do it is through these commands:

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
helm version

​ 3. k3s

k3s is the choice for local Kubernetes cluster. If you use another, feel free to do so.

  • Installation is easy, as it takes running only one command:

    curl -sfL https://get.k3s.io | sh -
    
  • The way to verify the health of the cluster(to make sure that they are all ready):

    • Nodes:

      sudo k3s kubectl get nodes
      
    • Pods:

      sudo k3s kubectl get pods --all-namespaces
      
  • Setting up the local cluster as the default one:

    Safest way in my opinion is to put the k3s cluster configuration file as the default one for kubectl. If you have already used kubectl and have cluster information for the clusters that you already have connected to, make sure to backup the configuration:

    mv ~/.kube/config ~/.kube/config_backup
    

    Then you can copy the k3s cluster configuration as the config file:

    sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
    
    sudo chown $USER:$USER .kube/config
    

There you have it. Cluster setup is done. Note: If you want to go back to existing clusters just copy the config_backup file back as config. ​

Deployment

​ For the deployment we will use the helm chart developed by Keitaro that can be found here. Clone the repository found on the given link: ​

git clone https://github.com/keitaroinc/ckan-helm
cd ckan-helm

​ To deploy CKAN on kubernetes cluster with a release name of your choosing, for this example ckan-deployment: ​

helm dependency update .
helm install ckan-deployment .

​ To follow the deployment until everything is properly deployed (it is normal to take a few minutes or so): ​

watch kubectl get pods

​ After that is completed, use the command: ​

kubectl get svc ckan

​ Under Cluster-IP you will find the local IP on which the CKAN instance is deployed on. Visiting that IP through the browser is going to take you to that instance. ​ Ex: Visiting 10.43.253.110 is taking me to: ​

Final thoughts

​In this blog we have seen how easy and practical it is to deploy your own CKAN instance locally using our Helm chart. But who does that locally instead of using cloud these days, right? Do not worry about that. In a series of blogs we will cover how you can use cloud to do that, as well. Stay tuned.

Leave a Reply