mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-02 16:53:58 +00:00
wip
This commit is contained in:
parent
cfb70bac24
commit
769b335b22
@ -8,7 +8,7 @@ The Ultimate Swiss Army knife for DevOps, Developers and Platform Engineers
|
||||
|
||||
| Steps | Playlist :tv: | Source :octocat: |
|
||||
|---|---|---|
|
||||
| Learn Kubernetes :snowflake: | <a href="https://www.youtube.com/playlist?list=PLHq1uqvAteVvUEdqaBeMK2awVThNujwMd" title="Kubernetes"><img src="https://i.ytimg.com/vi/8h4FoWK7tIA/hqdefault.jpg" width="50%" alt="Kubernetes Guide" /></a> | [source](./kubernetes/readme.md) |
|
||||
| [Learn Kubernetes](./kubernetes/README.md) :snowflake: | <a href="https://www.youtube.com/playlist?list=PLHq1uqvAteVvUEdqaBeMK2awVThNujwMd" title="Kubernetes"><img src="https://i.ytimg.com/vi/8h4FoWK7tIA/hqdefault.jpg" width="50%" alt="Kubernetes Guide" /></a> | [source](./kubernetes/readme.md) |
|
||||
| Learn about CI/CD tools :whale: | <a href="https://www.youtube.com/playlist?list=PLHq1uqvAteVsSsrnZimHEf7NJ1MlRhQUj" title="CI/CD"><img src="https://i.ytimg.com/vi/myCcJJ_Fk10/hqdefault.jpg" width="50%" alt="CI/CD Guide" /></a> | | | |
|
||||
| Deploy Kubernetes to the cloud :partly_sunny: | <a href="https://www.youtube.com/playlist?list=PLHq1uqvAteVsUhzNBkn-rPzXtPNpJu1-k" title="Cloud K8s"><img src="https://i.ytimg.com/vi/3jA9EfkSAUU/hqdefault.jpg" width="50%" alt="Cloud Guide" /></a> | [source](./kubernetes/cloud/readme.md) |
|
||||
| Monitoring Kubernetes :mag: | <a href="https://www.youtube.com/playlist?list=PLHq1uqvAteVuEXCrRkPFWLXRKWNLOVUHn" title="Cloud K8s"><img src="https://i.ytimg.com/vi/5o37CGlNLr8/hqdefault.jpg" width="50%" alt="Cloud Guide" /></a> | [source](./monitoring/prometheus/kubernetes/readme.md) |
|
||||
|
@ -1,4 +1,94 @@
|
||||
# Kubernetes Development Series <img src="https://www.shareicon.net/data/128x128/2017/04/11/883708_media_512x512.png" alt="YouTube" width="5%" height="5%"> :hammer::wrench:
|
||||
# Learn Kubernetes <img src="https://www.shareicon.net/data/128x128/2017/04/11/883708_media_512x512.png" alt="YouTube" width="5%" height="5%"> :hammer::wrench:
|
||||
|
||||
This guide is aimed to fast-track your Kubernetes learning by focusing on a practical hands-on overview guide. </br>
|
||||
This means, not too much of a deepdive, but enough to get a feel for the required building blocks of Kubernetes so you can align it with a real world problem that you are trying to solve. </br>
|
||||
|
||||
<b>The problem:</b> "I want to adopt Kubernetes" </br>
|
||||
<b>The problem:</b> "I have some common existing infrastructure"
|
||||
|
||||
<b>Our focus:</b> Solving the problem by learning each building block
|
||||
in order to port our infrastructure to Kubernetes.
|
||||
|
||||
## Docker installation
|
||||
|
||||
* Install Docker [here](https://docs.docker.com/get-docker/)
|
||||
|
||||
## Run Kubernetes
|
||||
|
||||
* Install `kubectl` to work with kubernetes
|
||||
|
||||
We'll head over to the [kubernetes](https://kubernetes.io/docs/tasks/tools/) site to download `kubectl`
|
||||
|
||||
* Install the `kind` binary
|
||||
|
||||
You will want to head over to the [kind](https://kind.sigs.k8s.io/) site
|
||||
|
||||
* Create a cluster
|
||||
|
||||
```
|
||||
kind create cluster
|
||||
```
|
||||
|
||||
## Namespaces
|
||||
|
||||
```
|
||||
kubectl create namespace cms
|
||||
```
|
||||
|
||||
## Deployments
|
||||
|
||||
* Deployment [documentation](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/)
|
||||
|
||||
cd kubernetes\tutorial
|
||||
|
||||
```
|
||||
kubectl -n cms apply -f deploy.yaml
|
||||
kubectl -n cms get pods
|
||||
|
||||
kubectl -n cms port-forward <pod-name> 80
|
||||
```
|
||||
|
||||
[Environment Variables](https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/) for pods
|
||||
|
||||
## Secrets
|
||||
|
||||
```
|
||||
kubectl -n cms create secret generic wordpress `
|
||||
--from-literal WORDPRESS_DB_HOST=mysql `
|
||||
--from-literal WORDPRESS_DB_USER=exampleuser `
|
||||
--from-literal WORDPRESS_DB_PASSWORD=examplepassword `
|
||||
--from-literal WORDPRESS_DB_NAME=exampledb
|
||||
|
||||
kubectl -n cms get secret
|
||||
|
||||
```
|
||||
[How to use](https://kubernetes.io/docs/concepts/configuration/secret/) secrets in pods
|
||||
|
||||
Apply changes to our deployment
|
||||
|
||||
```
|
||||
kubectl -n cms apply -f deploy.yaml
|
||||
```
|
||||
|
||||
We can `port-forward` again, and notice an error connecting to the database because the database does not exist
|
||||
|
||||
# Statefulset
|
||||
|
||||
Statefulset [documentation](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)
|
||||
|
||||
# Storage Class
|
||||
|
||||
StorageClass [documentation](https://kubernetes.io/docs/concepts/storage/storage-classes/)
|
||||
|
||||
# Services
|
||||
|
||||
Services [documentation](https://kubernetes.io/docs/concepts/services-networking/service/)
|
||||
|
||||
Let's deploy our `mysql` using what we learnt above:
|
||||
|
||||
```
|
||||
kubectl -n cms apply -f .\statefulset.yaml
|
||||
```
|
||||
|
||||
## Full playlist
|
||||
|
||||
|
42
kubernetes/tutorial/deploy.yaml
Normal file
42
kubernetes/tutorial/deploy.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: wordpress-deployment
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: wordpress
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
containers:
|
||||
- name: wordpress
|
||||
image: wordpress
|
||||
ports:
|
||||
- containerPort: 80
|
||||
env:
|
||||
- name: WORDPRESS_DB_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_HOST
|
||||
- name: WORDPRESS_DB_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_USER
|
||||
- name: WORDPRESS_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_PASSWORD
|
||||
- name: WORDPRESS_DB_NAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_PASSWORD
|
18
kubernetes/tutorial/ingress.yaml
Normal file
18
kubernetes/tutorial/ingress.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: wordpress
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: wordpress
|
||||
port:
|
||||
number: 80
|
14
kubernetes/tutorial/service.yaml
Normal file
14
kubernetes/tutorial/service.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: wordpress
|
||||
labels:
|
||||
app: wordpress
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
name: db
|
||||
targetPort: 80
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: wordpress
|
66
kubernetes/tutorial/statefulset.yaml
Normal file
66
kubernetes/tutorial/statefulset.yaml
Normal file
@ -0,0 +1,66 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mysql
|
||||
labels:
|
||||
app: mysql
|
||||
spec:
|
||||
ports:
|
||||
- port: 3306
|
||||
name: db
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: mysql
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: mysql
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: mysql # has to match .spec.template.metadata.labels
|
||||
serviceName: "mysql"
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: mysql # has to match .spec.selector.matchLabels
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 10
|
||||
containers:
|
||||
- name: mysql
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- containerPort: 3306
|
||||
name: db
|
||||
env:
|
||||
- name: MYSQL_DATABASE
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_PASSWORD
|
||||
- name: MYSQL_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_USER
|
||||
- name: MYSQL_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: wordpress
|
||||
key: WORDPRESS_DB_PASSWORD
|
||||
- name: MYSQL_RANDOM_ROOT_PASSWORD
|
||||
value: "1"
|
||||
volumeMounts:
|
||||
- name: db
|
||||
mountPath: /var/lib/mysql
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: db
|
||||
spec:
|
||||
accessModes: [ "ReadWriteOnce" ]
|
||||
storageClassName: "standard"
|
||||
resources:
|
||||
requests:
|
||||
storage: 500Mi
|
Loading…
x
Reference in New Issue
Block a user