Should you use Kubernetes? The short answer is that it depends. However, I will walk you through my journey to understanding Kubernetes. Perhaps it can help you find your own answer.
I wrote a book to guide you Road to Kubernetes (Get early release MEAP from Manning here). Before I talk about this book, let me talk a little bit about my introduction to the software and how I got there.
Nearly 20 years ago, I embarked on my first effort to deploy software on the Internet to publish my first website. At the time, I had no idea where to start. A few family friends were kind enough to give me some advice.
The entrepreneur suggested:
“Get this book on Dreamweaver and HTML and you won’t have to spend a penny developing your first website.”
System administrators and developers have taken different approaches, including:
“So let’s set up an FTP server to host our website. We don’t recommend learning how to manage a server.”
Both helped me get to where I am today, but one of them unintentionally delayed my learning for a long time. do you know who it is?
Looking back on my early years, I can see how both fundamental knowledge and hands-on learning were important in shaping my journey. His entrepreneurial advice actually got me into his web development. Also, under the guidance of a system administrator, I learned the value of tools that can simplify complex tasks.
However, one of the key lessons that became apparent over time was the importance of understanding the basic principles, even when working with high-level tools. This early learning experience was the beginning of his interest in Kubernetes, a technology that has had a major impact on my professional trajectory. Understanding Kubernetes, like any other tool, requires a solid understanding of the underlying technology.
Is Kubernetes complicated? Yes. Perfect? No. Is it suitable for all situations? But the question of whether to use Kubernetes is often your Understand the underlying technology that makes Kubernetes so powerful and how you can use it to manage and secure your software.
For those who are wondering “What is Kubernetes?” Or maybe you’re still unfamiliar with the relationship between the term “Docker” (besides the kind of pants) and containers. Please let me explain.
Every component of your application, from databases to programming languages, is constantly evolving and new versions are released frequently. Tracking multiple versions of each application and many iterations of third-party components can be difficult to manage, especially for older or legacy versions without mainstream support. Even supported versions of the software have numerous system-level and third-party installation dependencies that can complicate running the software, let alone using it as a component of an application. .
Over time, all software will eventually become obsolete and replaced by newer versions. The challenge lies in running old software when needed. Seemingly small changes in software can have a big impact on modern applications. For example, Python 2.7 (compared to the latest Python 3.11) was built into Apple’s Mac OS X. Python 2.7 had a strange syntax for outputting text to the command line. A more logical version of `print(“this thing”)` in newer versions of Python. This one syntax can break an entire traditional Python application due to missing parentheses.
While it may not be practical to use older versions of software, there are certainly situations where it is necessary to run older software. But how?
You can also spend time trying to find point-in-time hardware or VM images that can run older software. Alternatively, you can turn to containers, a concept pioneered by Docker. A container is a self-contained application that packages dependencies and can be modified as needed. Their unique selling point is their ability to seamlessly migrate from one system to another.
Below is an example Dockerfile that uses Python 2.7 as a container component.
```dockerfile
FROM python:2.7.7-slim
COPY ./src /app/
WORKDIR /app
RUN python -m pip install -r requirements.txt
CMD [“python”, “manage.py”, “runserver”]
```
```dockerfile
FROM python:2.7.7-slim
COPY ./src /app/
WORKDIR /app
RUN python -m pip install -r requirements.txt
CMD [“python”, “manage.py”, “runserver”]
```
This Dockerfile tells Docker what it needs to build this new container, using code that exists on your local machine and in a local path under “/src”. Dockerfiles can be more complicated, but this example shows how easy it is to use Docker.
Building and running this containerized application is as simple as:
```bash
docker build -f Dockerfile -t hello-python:v1 .
docker run hello-python -p 8000:8000
```
Without containerization, you would have to install Python 2.7 directly on your machine, which is never easy. Docker and other containers can make your application portable, and you can replace Python 2.7 in this example with almost any open source language or tool.
However, problems arise when updating containerized applications, especially in production. Updating the container locally is easy. Stop running the container, rebuild it, and then run it again. However, in production you can do container updates the same way, but at the risk of significant downtime if the build fails.
That’s where Kubernetes comes in. Kubernetes manages traffic routing to specific containers and monitors how many containers are running at any given time. In the event of a container failure, Kubernetes makes it easy to roll back to a previous version with little or no downtime.
The configuration for deploying containers on Kubernetes is manifest. Here’s an example of a relatively simple manifest:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-py-deploy
spec:
replicas: 3
selector:
matchLabels:
app: hello-py-deploy
template:
metadata:
labels:
app: hello-py-deploy
spec:
containers:
- name: hello-py-container
image: jmitchel3/hello-python:v1
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hello-py-service
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: 8080
protocol: TCP
selector:
app: hello-py-deploy
```
In the example above, the yaml-formatted Kubernetes manifest provisions two resources: a load balancing service and a deployment. A load balancer helps route traffic to your deployment. Via ‘replicas:3’ in declared container ‘hello-python:v1’ our deployment is running 3 versions of him.
If you want to update the deployed version, just change `hello-python:v1` to `hello-python:v2` and Kubernetes will successfully update your application. If anything goes wrong, it rolls back to “hello-py-deploy:v1”. Kubernetes makes this process painless and easier to manage. Manifests can be easily versioned using git, allowing very granular rollback capabilities. Kubernetes is essential to deployments because it provides a framework for automating, scaling, and managing containerized applications, ensuring system resilience and efficiency in increasingly complex software environments.
I wanted to share some of the ways you can discover how Kubernetes can simplify your application deployment. It took a few steps to get the most out of Kubernetes, but it was a worthwhile journey.of Road to KubernetesEmbark on a journey of deploying applications using a variety of technologies that are important to understand before embarking on Kubernetes and other modern deployment techniques.
of Road to Kubernetes We’ll show you how to:
- Manage Git repositories on self-hosted or cloud platforms
- Deploy Python and Node.js apps via cloud-based VMs with git
- Automate VM configuration and deployment with Ansible
- Containerize and deploy apps using Docker and Docker Compose
- Run containers directly on VMs without orchestration
- Push and host containers using the DockerHub registry
- Deploy containerized apps to Kubernetes
- Implement public and private apps on Kubernetes
- Configure a load balancer for HTTP and HTTPS traffic
- Using CI/CD techniques with Github Actions and open source alternatives with Nectos
Deployment is the final test of the software. Road to Kubernetes Fifteen years of implementation learning condensed into one accessible, practical guide. From deploying software from scratch to implementing Kubernetes functionality. Learn sustainable deployment practices that can be used in any language and any kind of web app, how to create portable applications that can be moved between deployment options and cloud providers, and how his Kubernetes can be used for projects of all sizes. to see if it is possible. .
Get the early release MEAP from Manning here as a first step towards understanding Kubernetes.