KCP on Power

Sneha Gaonkar
3 min readJun 13, 2022

--

KCP is a minimal Kubernetes API server, that only knows about basic types and CustomResourceDefinitions (CRDs). KCP doesn’t know about most of the core Kubernetes types (Pods, Deployments etc.), and expects users or controllers to define them as needed, and to run controllers to respond to those resources.

KCP is a generic CustomResourceDefinition apiserver that is divided into multiple “logical clusters” that enable multitenancy of cluster-scoped resources such as CRDs and Namespaces. Each of these logical clusters is fully isolated from the others, allowing different teams, workloads, and use cases to live side by side.

Kubernetes is used by many users on IBM Power platform and it would be great if users can take advantage of KCP features on ppc64le architecture as well. In this blog, we will see how we can get started with KCP on Power by deploying a simple Go Application.

Pre-requisites

  • IBM Power resource for deploying KCP server

You can use the PowerVS service at IBM Cloud or Minicloud to get your ppc64le virtual machine. This example uses a CentOS 8 ppc64le VM.

  • Install Go
git clone https://github.com/rpsene/goconfig.gitcd ./goconfigsource ./go.sh install
  • Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/ppc64le/kubectl"chmod +x kubectl
  • Install kind
curl -Lo ./kind "https://github.com/kubernetes-sigs/kind/releases/download/v0.14.0/kind-linux-ppc64le"chmod +x ./kindmv ./kind /usr/local/bin/
  • Install Docker
mkdir /root/docker; cd /root/dockerwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-cli-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/docker-ce-rootless-extras-20.10.10-3.el8.ppc64le.rpmwget https://download.docker.com/linux/centos/8/ppc64le/stable/Packages/containerd.io-1.4.11-3.1.el8.ppc64le.rpmyum localinstall containerd.io-1.4.11-3.1.el8.ppc64le.rpm docker-ce-cli-20.10.10-3.el8.ppc64le.rpm docker-ce-20.10.10-3.el8.ppc64le.rpm docker-ce-rootless-extras-20.10.10-3.el8.ppc64le.rpmservice docker start

Deploy KCP server on Power

  1. Clone KCP source code
git clone https://github.com/kcp-dev/kcp.git

2. Build KCP server binary and install kubectl kcp plugin

cd kcp && makemake installgo install ./cmd/...export PATH=$PWD/bin:$PATH

3. Start KCP server

kcp start

4. In another terminal, set KUBECONFIG to access the kcp server. Check the available api-resources on the accessed server. Notice that CRDs like Pods, Deployments are not available.

cd kcpexport KUBECONFIG=/root/kcp/.kcp/admin.kubeconfigkubectl api-resources

Deploy application on KCP server

  1. Create a new organization and workspace to deploy the application in isolated environment.
  • First check your current workspace, using below command:
kubectl kcp workspace .

The output will be something like root:users:ev:vo:system-apiserver.

  • Navigate to root workspace using below command multiple times(4 times in our case)until you reach root workspace:
kubectl kcp workspace ..
kubectl kcp workspace create --type=Organization org1kubectl get workspaces       //list workspaceskubectl kcp workspace use org1     //enter organization
kubectl kcp workspace create workspace1kubectl get workspaces       //list workspaceskubectl kcp workspace use workspace1    //enter workspace

2. Generate the Syncer resource configuration pointing to your kind workload cluster.

kubectl create namespace defaultkubectl kcp workload sync <cluster-name> --syncer-image ghcr.io/kcp-dev/kcp/syncer:main -o syncer.yaml

3. Create kind workload cluster for deploying the application. Use the same cluster name as used in previous step.

kind create cluster --image docker.io/mwaghmodepersistent/kindnode:ppc64le --name <cluster-name>

4. Create syncer resource

kubectl apply -f syncer.yamlkubectl api-resources

This syncer will be responsible for syncing all the resources between you kcp workspace and kind workload cluster. It will automatically create required CRDs (like Deployment etc.) in your workspace.

5. Clone application source code repository and create the deployment.


git clone https://github.com/snehakpersistent/golang-hello-world.git
cd golang-hello-worldkubectl apply -f deployment.yamlkubectl get pods

6. Expose the application by using port-forwarding

kubectl port-forward --address localhost,<public-ip-of-VM> <pod-name> 3000:3000

You can access the application in your browser at http://<public-ip-of-VM>:3000

That’s all folks! Thanks for reading. Hope you found this tutorial helpful :)

--

--

Sneha Gaonkar
Sneha Gaonkar

No responses yet