Skip to content

romanwrites/ft_services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_services

Learning to use Kubernetes

Photo by Borderpolar Photographer on Unsplash


"Kubernetes is an open source project that enables software teams of all sizes, from a small startup to a Fortune 100 company, to automate deploying, scaling, and managing applications on a group or cluster of server machines. These applications can include everything from internal-facing web applications like a content management sysrtem to marquee web properties like Gmail to big data processing."

— Joe Beda

About

The project goal is to create a kubernetes cluster with: nginx, phpmyadmin, wordpress, ftps, mysql, grafana, telegraf and influxdb.

To get familiar with useful software and learn how to configure and run all of it in k8s.

Install

git clone https://github.com/kukinpower/ft_services.git
cd ft_services
sh setup.sh

⏱ Save your time

Custom cli dashboard

Feel free to use my_dashboard.sh to see pretty k8s custom dashboard in your cli

sh my_dashboard.sh

Custom aliases

My k8s aliases

alias k=kubectl
alias ks="k get svc"
alias kp="k get po"
alias kd="k get deployments"
alias md="minikube stop && minikube delete"

Enabling zsh autocompletion

Add this to ~/.zshrc

source <(kubectl completion zsh)

Useful commands

kubectl get pods
kubectl get replicaset
kubectl create deployment nginx-deployment --image=nginx
kubectl edit deployment [name]
kubectl logs [pod name]
kubectl exec -it [pod name] -- bin/sh
kubectl cp [pod name]:[dir or file name] [desired path to dir or file name]

🕵🏼‍♀️ Research

Kubernetes has a plug-n-play architecture that allows to extend it when need to.

Health checks are available from a box. Such as: TCP, HTTP or container execution.

Pod

Pod is container in k8s

Pods can be assigned to nodes

Pods can use persistent volumes to store data

In Kubernetes, all containers run in pods.

Some examples:

kubectl create deployment nginx --image=nginx:1.10.0

kubectl get pods to view the pods.

To expose the nginx container outside Kubernetes kubectl expose deployment nginx --port 80 --type LoadBalancer

kubectl get services to view services

kubectl scale deployment nginx --replicas 3 creates 3 replica pods

built-in pod documentation kubectl explain command

kubectl describe pods [NAME] to get more info

kubectl port-forward to map a local port to a port inside the monolith pod

kubectl port-forward monolith 10080:80

How to see which node a pod belongs?

kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name --all-namespaces

or simply kubectl get pods -o wide

kubectl logs -f monolith to get a stream of logs in real time

Deployment manages a ReplicaSet Replicaset manages a Pod Pod is an abstraction of Container

Author

Roman Kukin