
Last year AWS was about to ban the “multi-cloud” term in co-branding guides for Partners, removed the ban after community and partners critique, and now embraces multi-cloud strategy.
One of the products that AWS announced during its last re:Invent was Amazon EKS Distro — Kubernetes distribution based on and used by Amazon Elastic Kubernetes Service. It is interesting because it is the first step to the new service — EKS Anywhere — which enables AWS customers to run EKS anywhere, even on bare-metal or any other cloud, and later allows them to seamlessly migrate from on-prem EKS directly to AWS.
In this blog post, we will show how easy it is to spin up Amazon EKS Distro (EKS-D) and set up MongoDB with Percona Kubernetes Operator for Percona Server for MongoDB.
Let the Show Begin
Give Me the Cluster
I just spun up the brand new Ubuntu 20.10 virtual machine. You can spin it up anywhere, I myself use Multipass — it gives command-line interface to launch Linux machines locally in seconds.
Installing EKS-D on Ubuntu is one command “effort”:
$ sudo snap install eks --classic --edge Run configure hook of "eks" snap if present eks (1.18/edge) v1.18.9 from Canonical✓ installed
EKS on Ubuntu gives the same look and feel as microk8s — it has its own command line (eks) and allows you to add/remove nodes easily if needed. Read more here.
Check if EKS is up and running:
# eks status eks is running high-availability: no datastore master nodes: 127.0.0.1:19001 datastore standby nodes: none
eks kubectl
gives you direct access to regular Kubernetes API. Hint: you can get configuration from eks and put it into .kube
folder to control EKS with kubectl
(you may need to install it). I’m lazy and will continue using eks kubectl
.
# mkdir ~/.kube/ ; eks config > ~/.kube/config # eks kubectl get pods -n kube-system NAME READY STATUS RESTARTS AGE calico-node-rrsbd 1/1 Running 1 15m calico-kube-controllers-555fc8cc5c-2ll8f 1/1 Running 0 15m coredns-6788f546c9-x8q7l 1/1 Running 0 15m metrics-server-768748c8f4-qpxnp 1/1 Running 0 15m hostpath-provisioner-66667bf7f-pfg8s 1/1 Running 0 15m
hostpath-provisioner
is running, which means the host path based storage class needed for the database is already there.
Give Me the Database
As promised we will use Percona Kubernetes Operator for Percona Server for MongoDB to spin up the database. And it is the same process described in our minikube installation guide (as long as you run 1 node only).
Get the code from github:
# git clone -b v1.5.0 https://github.com/percona/percona-server-mongodb-operator # cd percona-server-mongodb-operator
Deploy the operator:
# eks kubectl apply -f deploy/bundle.yaml customresourcedefinition.apiextensions.k8s.io/perconaservermongodbs.psmdb.percona.com created customresourcedefinition.apiextensions.k8s.io/perconaservermongodbbackups.psmdb.percona.com created customresourcedefinition.apiextensions.k8s.io/perconaservermongodbrestores.psmdb.percona.com created role.rbac.authorization.k8s.io/percona-server-mongodb-operator created serviceaccount/percona-server-mongodb-operator created rolebinding.rbac.authorization.k8s.io/service-account-percona-server-mongodb-operator created deployment.apps/percona-server-mongodb-operator created
I have one node in my fancy EKS cluster and I will
- Change the number of nodes in a replica set to 1 (
size: 1
) - Remove the
antiAffinity
configuration - Set
allowUnsafeConfigurations
flag to true indeploy/cr.yaml
. This flag set totrue
allows users to run unsafe configurations (like 1 node MongoDB cluster), this is useful for development or testing purposes, but of course not recommended for production.
spec: ... allowUnsafeConfigurations: true replsets: - name: rs0 size: 1 # affinity: # antiAffinityTopologyKey: "kubernetes.io/hostname"
Now, give me the database:
# eks kubectl apply -f deploy/cr.yaml 1 minute later… # eks kubectl get pods NAME READY STATUS RESTARTS AGE percona-server-mongodb-operator-6b5dbccbd5-jh9x8 1/1 Running 0 7m35s my-cluster-name-rs0-0 2/2 Running 0 77s
Simple as that!
Conclusion
Setting up Kubernetes locally can be easily done not only with EKS Distro, but with minikube, microk8s, k3s, and other distributions. The true value of EKS-D will be shown once EKS Anywhere goes live in 2021 and unlocks the multi-cloud Kubernetes. Percona has always been an open source company: we embrace, value, and heavily invest in multi-cloud ecosystems. Our Kubernetes Operators for Percona XtraDB Cluster and MongoDB enable businesses to run their data on Kubernetes on any public or private cloud without lock-in. We also provide full support for our operators and databases running on your Kubernetes cluster.