Deploy an app to AWS EKS cluster through Razorops
Lets deploy an app to our previous created cluster. We will define a .razorops.yaml file in home directory of our app which we want to deploy on our cluster.
Please note that while adding cluster we added it with the name "razorops-cluster". In our .razorops.yaml file, we will mention that use that cluster to do any operations or to make any server API calls.
As we have previously seen how we construct the .razorops.yaml file and what all tasks we can define in it. Please check the previous guide for more reference.
Lets say we have a docker image of demo app that we want to deploy. How to use Docker images properly, please refere here.
- You have already defined deployment in your cluster. Lets say deployment name is "web"
- You have already defined an imagepullsecrets for your service account.
- If your Docker image registry needs to get the fresh token for access, then you have defined a cron job to do so.
- Your Docker image registry has the build image, with or without tags as per your requirements.
- You have integrated the versioning control tools e.g github, gitlab etc.
Our .razosops.yaml file is quite simple as follow:
Cluster Name = razorops-cluster # we defined it in razorops website while adding the cluster. namespace = default # because our service account through which we are doing this deployment is under default namespace Deployment Name = web # this is already defined in our cluster.
tasks: deploy-k8s: image: lachlanevenson/k8s-kubectl:v1.11.8 environment: name: prod cluster: name: razorops-cluster commands: - kubectl -n default set image deployment.v1.apps/web web=docker-image-url:latest workflow: - name: production tasks: [deploy-k8s] when: branch == "master"
Here we are defining a task named deploy-k8s, you can mention any name. Under environment, we mention our cluster name which we created in razorops website while adding cluster.
Under commands, we are simply defining that kubernetes changes the deployment's image to your docker-image-url:latest
Instead of latest, you can define your own tag and use that.
Workflow states that when you push your code to master branch of your repository, then this task will be triggered automatically.