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.
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”:
|
1 |
$ sudo snap install eks --classic --edge<br>Run configure hook of "eks" snap if present <br>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:
|
1 |
# eks status<br>eks is running<br>high-availability: no<br> datastore master nodes: 127.0.0.1:19001<br> 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.
|
1 |
# mkdir ~/.kube/ ; eks config > ~/.kube/config<br># eks kubectl get pods -n kube-system<br>NAME READY STATUS RESTARTS AGE<br>calico-node-rrsbd 1/1 Running 1 15m<br>calico-kube-controllers-555fc8cc5c-2ll8f 1/1 Running 0 15m<br>coredns-6788f546c9-x8q7l 1/1 Running 0 15m<br>metrics-server-768748c8f4-qpxnp 1/1 Running 0 15m<br>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.
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:
|
1 |
# git clone -b v1.5.0 https://github.com/percona/percona-server-mongodb-operator<br># cd percona-server-mongodb-operator |
Deploy the operator:
|
1 |
# eks kubectl apply -f deploy/bundle.yaml<br>customresourcedefinition.apiextensions.k8s.io/perconaservermongodbs.psmdb.percona.com created<br>customresourcedefinition.apiextensions.k8s.io/perconaservermongodbbackups.psmdb.percona.com created<br>customresourcedefinition.apiextensions.k8s.io/perconaservermongodbrestores.psmdb.percona.com created<br>role.rbac.authorization.k8s.io/percona-server-mongodb-operator created<br>serviceaccount/percona-server-mongodb-operator created<br>rolebinding.rbac.authorization.k8s.io/service-account-percona-server-mongodb-operator created<br>deployment.apps/percona-server-mongodb-operator created |
I have one node in my fancy EKS cluster and I will
|
1 |
spec:<br>...<br> allowUnsafeConfigurations: true<br> replsets:<br> - name: rs0<br> size: 1<br># affinity:<br># antiAffinityTopologyKey: "kubernetes.io/hostname" |
Now, give me the database:
|
1 |
# eks kubectl apply -f deploy/cr.yaml<br>1 minute later…<br># eks kubectl get pods<br>NAME READY STATUS RESTARTS AGE<br>percona-server-mongodb-operator-6b5dbccbd5-jh9x8 1/1 Running 0 7m35s<br>my-cluster-name-rs0-0 2/2 Running 0 77s |
Simple as that!
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.