Using Kubernetes

How to run MarketGrid in a Kubernetes cluster.

This section will guide you through running MarketGrid using Kubernetes. This is for cloud deployment, or testing using a local Kubernetes cluster.

To follow this guide, you will need access to a Kubernetes cluster, either via a cloud provider or using a local Kubernetes distribution such as Kind or Minikube.

Kubernetes is highly flexible and there are many ways to deploy applications into a Kubernetes cluster. For the purposes of this guide, we will be using Helm to deploy MarketGrid.

Prerequisites

To follow this guide, you will need to install:

Setting up a local cluster

This section will guide you through setting up a local Kubernetes cluster into which we can deploy MarketGrid. If you are already connected to a Kubernetes cluster, you can skip this section.

Install Kubernetes

curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Create the cluster

kind create cluster --config=- <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP
EOF
minikube start

Configure ingress to the cluster

This step is required so as to allow HTTP traffic to pass from the host into the MarketGrid container that will run inside the cluster.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
minikube addons enable ingress

Installing MarketGrid

Configure the MarketGrid Helm repository

Add the MarketGrid Helm chart repository.

helm repo add marketgrid https://charts.marketgrid.systems

Install the MarketGrid chart

We first need to create a values.yaml file that will configure the MarketGrid deployment with:

  • the name of your organisation (so as to pull the correct image)
  • the credentials needed to pull the image
  • the image version to pull
  • the start command for the MarketGrid container

You will need a GitLab user ID that has been granted access to the MarketGrid charts project, and a personal access token for that user. In the snippet below, substitute the variable references with the actual values.

org: ccmx
imageCredentials:
  registry: registry.cartax.io
  username: ${GITLAB_USERNAME}
  password: ${GITLAB_TOKEN}
image:
  tag: v3.5.6
  command: ['mg']
  args: ['start', 'ccmx_test_data_nokk']

Now the chart can be deployed using helm install, using the values.yaml file that we created above.

helm install marketgrid marketgrid/marketgrid -f values.yaml

Verify that the MarketGrid UI is accessible:

curl http://localhost/
curl http://$(minikube ip)/

Note: In Minikube, services are only exposed to the host machine. If connecting from another location, you will need to configure a tunnel, which is beyond the scope of this guide.