78 points by gophers_for_life 6 months ago flag hide 16 comments
mikeserv 6 months ago next
Nice write-up, really enjoyed reading it! Well done on building a serverless API with Kubernetes and Go. I am planning to use the same stack this week. Best wishes!
andrew47 6 months ago next
Thanks for the kind words @mikeserv! Good luck with your implementation, let us know how it goes! It would be great if you can share your experience with the community as well.
bigdave 6 months ago prev next
I tried doing something similar, but my containers kept dying. I assume from an infinite loop, but I'm struggling to find the cause. Any suggestions?
mikeserv 6 months ago next
@bigdave I know that drill! In situations like this, it's crucial to examine your container logs for any signs of failure. Assuming your containers are Docker containers, you can peek into their logs using the 'docker logs <container-id>' command. I've seen cases where APIs consumed by the container have misbehaved, leading the container to crash. Carefully observe your container hunger patterns or any resource constraints you might be putting on them, as they might have a cause-effect relationship to the infinite loop.
thecodingengineer 6 months ago prev next
@mikeserv That's great to hear, I was just going through some docs and examples about serverless APIs, leveraging Kubernetes and Go. Do you mind sharing the source code and some key insights about pitfalls and best practices you've encountered?
mikeserv 6 months ago next
@thecodingengineer Of course! Here's the link: <https://github.com/mikeserv/my-serverless-api>. Make sure to read through the README file, I've jotted down some opinions there. As for best practices, I'd say YAML linting, custom Kubernetes resource definitions, Go Modules, and ingress controllers are essential for a good implementation!
k8sfan 6 months ago prev next
impressive article! Do you have a roadmap charting the development of this project, or a simple milestones-focused outline? I'm thinking about setting up something similar and would like to know how you unfurled the leaves, as it were.
mikeserv 6 months ago next
@k8sfan Not exactly a roadmap, but we have a GitHub projects board publicly available here: <https://github.com/mikeserv/my-serverless-api/projects/>. You'd be able to see the sprint milestones and issues we've grouped on the board. Happy to help if you want to know more!
dave_dev 6 months ago prev next
@mikeserv Fantastic read. I've dabbled in the past with similar setups, but I've never tried combining K8s and Go. Do you happen to have a particular piece of documentation or guide you recommend on understanding Kubernetes requirements in this specific context? This would be very helpful when diving into the codebase.
random_engineer 6 months ago next
@dave_dev While mikeserv has the perfect write-up right here on HN, I'd recommend looking into the official Kubernetes documentation concerning service to service communications: <https://kubernetes.io/docs/concepts/services-networking/>. This should set you up with a baseline that mikeserv expands on using Go.
mikeserv 6 months ago next
@random_engineer Appreciate the backup here. Totally agree with your suggestions @dave_dev, you'll find my write-up much more digestible if you understand the baseline concepts of service to service communication. Happy hacking and best of luck!
marie_jam 6 months ago prev next
Very impressive, thanks for sharing! I'm curious about the monitoring and logging configuration, could you explain the toolset you used and any best practices you might have picked up on? That'd be rad!
mikeserv 6 months ago next
@marie_jam Prometheus and Grafana are our go-to monitoring tools for most of our engineers: <https://prometheus.io/> and <https://grafana.com/>. We have also started adopting VMware's new Tanzu Observability by Wavefront, which, while not open-source, is an exciting project to follow: <https://tanzu.vmware.com/observability>. As for logging, I generally swear by Fluentd, but you might want to check the ELK (Elasticsearch, Logstash, and Kibana) Stack if you're interested in a more all-in-one solution for your logging: <https://www.elastic.co/elk-stack>.
the_non_conformist 6 months ago prev next
You certainly seem to know what you're talking about. I wish I had that insight when I first started exploring serverless API solutions. Were there any daunting challenges you faced while setting this up, and how did you overcome them?
mikeserv 6 months ago next
@the_non_conformist Thanks! I'm flattered by your assumption, but my expertise is only marginally better than yours. I faced many challenges in my journey, two of which stood out. The first was migrating from Jenkins to GitHub Actions, as I wrote about earlier <https://news.ycombinator.com/item?id=24912423>. The other involved deciphering the complexities around ingress-based load balancing, specifically when using L7 load balancers like the NGINX ingress controller: <https://kubernetes.github.io/ingress-nginx/how-it-works/>.
former_sysadmin 6 months ago next
@mikeserv Cheers for providing these hyperlinks! I too have suffered through that excruciating transition from Jenkins to GitHub Actions. While it's a more sophisticated yet convoluted foe, I rest assured knowing I'm not the only one that has been through that! Also, thanks for sharing the link about ingress-based load balancing; I'm sure that would suit my current projects.