My experience setting up a Kitura web server

Many may know Swift as the language for IOS development, but that all changed in 2016, when Apple announced that It would make Swift an open source language! IBM and many others started making web frameworks! One of them would be known as Kitura. Kitura is a web framework that is entirely built on Swift!! Being a big fan of the language, I couldn’t help but take on the challenge of setting up a web server with my favorite computer language. With the help of Kitura tutorials, not only would I learn how to create an API server, I would also learn about deployment technologies such as Docker and Kubernetes. This project would help me reflect the skills I have now and demonstrate the new challenges I’ll have learn as a software engineer.
Before I started this project
It was 2018 and I had recently bought my first MacBook from a friend. I always had an interest in developing IOS apps and now that I finally had a Mac, I could start building one. That’s when I first encountered Swift, the only language I knew so far was C++ and Java, when I started programming in Swift, It was a different syntax, but one I would later enjoy. The function calls made things more readable, the protocols would make sure implementations were right! After a few months of practicing and creating simple apps, I started enjoying my experience with Swift. It was all practical and easy to adapt to. Fast forward to a few months later, I being may journey in Holberton School. January 27th Cohort 8, with the help of my peers and school staff, I would go on to learn a lot more about software development. I learned how to make my first custom shell, entirely built in C in just three months. The next three months we had the new task of learning a new language called Python. Python reminded me a lot about Swift, except for those pesky indentation errors. We learned how to create a console for our upcoming Airbnb clone. The last three months of the year would be spent learning about API’s and servers. We were set to tackle a full stack project! That’s when I encountered the Kitura Web server, after a year of experimenting with IOS and 9 months of Holberton’s Full stack challenges, I was ready to learn everything there is to learn about the Kitura web framework. This project was perfect for me, I wanted to mix everything I’ve experienced into one three week project. Here are some of my accomplishments
The architecture

Here’s how the completed architecture would be. The cloud on top is meant to demonstrate a Kubernetes cluster. This cluster would contain three types of services, the first one being the Kitura web server. The Kitura web server would be deployed in a docker container, which is publicaly available at Docker Hub. With the image being available publicly, Kubernetes would be able to pull the image into a pod and create three duplicates of the image. These three pods would handle the emojions api request. Traffic would be balanced trough the second service Nginx. This service would be provided by Helm’s stable Nginx chart. With the help of Nginx load balancer, we could divide work to each pod, allow the flow of request traffic to be smooth. The last one is a simple Postgresql service. It was also installed from Helm’s stable chart. With the database in place, we would be able to store emoji entries for as long as the user would like. With this setup, we would be able to serve users from both the web and iOS! The iOS would need a properly setup app that would communicate with the server and receive the saved entries from the user.

Here’s a representation of the technologies that were used in this project. The backend would consist of only one language, Swift!! This would be possible with the help of the Kitura web framework. The Kitura web framework provided the architecture, the Docker file and the Kubernetes chart to properly set up the emojion’s project. We would use postgresql to store user information and its entries. For the front-end, we used css, html and javascript for the simple client site that would ask for user entry of emojis. For deployment, we used Nginx to balance traffic, Docker to publicly provide the running Kitura web server image and Kubernetes to run the services required for the client to communicate with the server. Here are three key feature from this project.
Functionalities


The challenges
One of the major challenges I had faced during the making of this project was deploying it to the cloud. I had succeeded in using Kubernetes locally from my Docker desktop. If it worked locally, then it can worked anywhere! I still didn’t have any idea what Kubernetes was, I had simply followed instructions from Kitura. The same couldn’t be said when it came to importing a cluster from a different provider. I initially started off with IBM’s cloud services, they provided me with a free first time Kubernetes cluster! When I imported it, I still wasn’t sure if I was using Docker’s cluster or IBM’s cluster. There was no message mentioning I had switched and no indication showing which one I was using. So I went to my .kube folder and copied the IBM ylm file and pasted it on the settings. Finally after an entire day of research, I had my k8s server setup! All I need to do is follow the instrcutions again and have it running. The docker image is deploy, the nginx loadbalancer is deployed and the postgresql is deployed! Wow now its time to checkout the Kubernetes dashboard and see everything is alright. I then noticed an error on the persistence volume claim 😱. I start en entire day of research looking for the solution. I then realized that I had not purchased a postgresql database! Ok this should be simple, I purchase one but somehow have no idea how to make it communicate with my cluster. I then give up and try out another type. Since it ran locally, I can surely run use one that runs locally as well! That’s when I stumbled upon minikube. They provide you with an IP address that can be for the Kubernetes cluster. They even have special commands that give you access to many other tools. It would have been perfect! I follow the same steps and I still struggle with deployment. I have three days left until presentation, I needed a quick solution. Kubernetes was created by Google, so why not use their tools?! I went ahead and purchased their service, this time everything ran smoothly, no missing persistence volume claim, all services were running as they should. I still got error messages from my website. There was no more time to mess around, I had two days left until presentation, I had to choose a different battle and left the deployment to rest. It was time to work on my presentation.
The outcome
This journey demonstrated the complexity of deploying an application, specially when it came to using Kubernetes. But testing it and experimenting with it also helped me learn a lot more about it. This experience gave me the same experience I had when I started learning at Holberton School. The constant research and fixing was thrilling, but it also took me down many rabbit holes, taking away the time I could’ve used on preparing for my presentation. Many of which could’ve been delt with if I was surrounded around my peers. The day before my presentation, I was surprised by the amount of help my peers were attempting to provide, solutions I wish I had time apply. I personally believe I would have successfully deployed it if I had gone to Holberton School during the deployment process, I would have avoided many rabbit holes that took so much time out of my schedule. It taught me the true value of peer learning. This process also made me even more excited for Swift and it’s use in web development. Learning about Kitura was an enjoyable moment and the struggle of deploying it in Kubernetes made me want to learn about it even more. I realized the potential of using Kubernetes and I look forward to learning more. I’d also like to apply Kitura in future web development, maybe even try out another web framework called Vapor.
About me
I’m currently a software engineer student studying in an amazing school called Holberton. This school has taught me the values of proper team communication, peer learning and learning. I’ve completed my first year of full stack foundations and will soon enter my second year to learn all about Machine learning. I’m an apple enthusiast and love the tools they provide to developers and I also love to learn about iOS development.
