This Blog post contains a Vagrantfile, a Python application, and a MinIO installation script, all containerized using Docker and orchestrated using Docker Compose.
Prerequisites
- Vagrant
- Docker
- Docker Compose
The Repo Link Here
For the people who think differently Welcome aboard
This Blog post contains a Vagrantfile, a Python application, and a MinIO installation script, all containerized using Docker and orchestrated using Docker Compose.
The Repo Link Here
multi.yml:apiVersion: v1
kind: Pod
metadata:
name: multi
namespace: baz
spec:
containers:
- name: nginx
image: nginx
- name: redis
image: redis
apiVersion: v1
kind: Pod
metadata:
name: logging-sidecar
namespace: baz
spec:
containers:
- name: busybox1
image: busybox
command: ['sh', '-c', 'while true; do echo Logging data > /output/output.log; sleep 5; done']
volumeMounts:
- name: sharedvol
mountPath: /output
- name: sidecar
image: busybox
command: ['sh', '-c', 'tail -f /input/output.log']
volumeMounts:
- name: sharedvol
mountPath: /input
volumes:
- name: sharedvol
emptyDir: {}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: np-maintenance
namespace: foo
spec:
podSelector:
matchLabels:
app: maintenance
policyTypes:
- Ingress
- Egress
Create a Networkpolicy That Allows All Pods in the users-backend Namespace to Communicate with Each Other Only on a Specific Port
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: np-users-backend-80
namespace: users-backend
spec:
podSelector: {}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
app: users-backend
ports:
- protocol: TCP
port: 80
Cheers
Osama
1) Linux :
Basic Linux commands are necessary before jumping into shell scripting.
* https://lnkd.in/dBTsJbhz
* https://lnkd.in/dHQTiHBB
* https://lnkd.in/dA9pAmHa
2. Shell Scripting:
* https://lnkd.in/da_wHgQH
* https://lnkd.in/d5CFPgga
3. Python: This will help you in automation
* https://lnkd.in/dFtNz_9D
* https://lnkd.in/d6cRpFrY
* https://lnkd.in/d-EhshQz
4. Networking
* https://lnkd.in/dqTx6jmN
* https://lnkd.in/dRqCzbkn
5. Git & Github
* https://lnkd.in/d9gw-9Ds
* https://lnkd.in/dEp3KrTJ
6. YAML
https://lnkd.in/duvmhd5X
https://lnkd.in/dNqrXjmV
7. Containers — Docker:
* https://lnkd.in/dY2ZswMZ
* https://lnkd.in/d_EySpbh
* https://lnkd.in/dPddbJTf
8. Continuous Integration & Continuous Deployment (CI/CD):
9. Container Orchestration — Kubernetes:
* https://lnkd.in/duGZwHYX
10. Monitoring:
* https://lnkd.in/dpXhmVqs
* https://lnkd.in/dStQbpRX
* https://lnkd.in/de4H5QVz
* https://lnkd.in/dEtTSsbB
11. Infrastructure Provisioning & Configuration Management (IaC): Terraform, Ansible, Pulumi
* https://lnkd.in/dvpzNT5M
* https://lnkd.in/dNugwtVW
* https://lnkd.in/dn5m2NKQ
* https://lnkd.in/dhknHJXp
* https://lnkd.in/ddNxd8vU
12. CI/CD Tools: Jenkins, GitHub Actions, GitLab CI, Travis CI, AWS CodePipeline + AWS CodeBuild, Azure DevOps, etc
* https://lnkd.in/dTmSXNzv
* https://lnkd.in/dAnxpVTe
* https://lnkd.in/daMFG3Hq
* https://lnkd.in/dqf-zzrx
* https://lnkd.in/diWP7Tm7
* https://lnkd.in/dYDCSiiC
13. AWS:
* https://lnkd.in/dmi-TMv9
* https://lnkd.in/de3-dAB6
* https://lnkd.in/dh2zXZAB
* https://lnkd.in/dQMyCBWy
14. Learn how to SSH
SSH using mobaxterm:
15. SSH using Putty :
The below is now Free courses on Udemy, not sure till when so enjoy as you can.
Free learning on Udemy DevOps Tutorials for Absolute Beginner
Cheers
Osama
It’s super simple command
kubectl create sa webautomation -n web
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: pod-reader
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
Bind the ClusterRole to the Service Account to Only Read Pods in the web Namespace
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: rb-pod-reader
namespace: web
subjects:
- kind: ServiceAccount
name: webautomation
roleRef:
kind: ClusterRole
name: pod-reader
apiGroup: rbac.authorization.k8s.io
Cheers
Osama
PersistentVolumes provide a way to treat storage as a dynamic resource in Kubernetes. This lab will allow you to demonstrate your knowledge of PersistentVolumes. You will mount some persistent storage to a container using a PersistentVolume and a PersistentVolumeClaim.
Create a custom Storage Class by using “`vi localdisk.yml`.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: localdisk
provisioner: kubernetes.io/no-provisioner
allowVolumeExpansion: true
Finish creating the Storage Class by using kubectl create -f localdisk.yml.
Create the PersistentVolume by using vi host-pv.yml.
kind: PersistentVolume
apiVersion: v1
metadata:
name: host-pv
spec:
storageClassName: localdisk
persistentVolumeReclaimPolicy: Recycle
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /var/output
Finish creating the PersistentVolume by using kubectl create -f host-pv.yml.
Check the status of the PersistenVolume by using kubectl get pv
Start creating a PersistentVolumeClaim for the PersistentVolume to bind to by using vi host-pvc.yml.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: host-pvc
spec:
storageClassName: localdisk
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
Finish creating the PersistentVolumeClaim by using kubectl create -f host-pvc.yml.
Check the status of the PersistentVolume and PersistentVolumeClaim to verify that they have been bound:
kubectl get pv
kubectl get pvc
Create a Pod that uses the PersistentVolumeClaim by using vi pv-pod.yml.
apiVersion: v1
kind: Pod
metadata:
name: pv-pod
spec:
containers:
- name: busybox
image: busybox
command: ['sh', '-c', 'while true; do echo Success! > /output/success.txt; sleep 5; done']
Mount the PersistentVolume to the /output location by adding the following, which should be level with the containers spec in terms of indentation:
volumes:
- name: pv-storage
persistentVolumeClaim:
claimName: host-pvc
In the containers spec, below the command, set the list of volume mounts by using:
volumeMounts:
- name: pv-storage
mountPath: /output
Finish creating the Pod by using kubectl create -f pv-pod.yml.
Check that the Pod is up and running by using kubectl get pods.
If you wish, you can log in to the worker node and verify the output data by using cat /var/output/success.txt.
Kubernetes volumes offer a simple way to mount external storage to containers. This lab will test your knowledge of volumes as you provide storage to some containers according to a provided specification. This will allow you to practice what you know about using Kubernetes volumes.
apiVersion: v1
kind: Pod
metadata:
name: maintenance-pod
spec:
containers:
- name: busybox
image: busybox
command: ['sh', '-c', 'while true; do echo Success! >> /output/output.txt; sleep 5; done']
volumes:
- name: output-vol
hostPath:
path: /var/data
volumeMounts:
- name: output-vol
mountPath: /output
The complete YAML will be
apiVersion: v1
kind: Pod
metadata:
name: maintenance-pod
spec:
containers:
- name: busybox
image: busybox
command: ['sh', '-c', 'while true; do echo Success! >> /output/output.txt; sleep 5; done']
volumeMounts:
- name: output-vol
mountPath: /output
volumes:
- name: output-vol
hostPath:
path: /var/data
apiVersion: v1
kind: Pod
metadata:
name: shared-data-pod
spec:
containers:
- name: busybox1
image: busybox
command: ['sh', '-c', 'while true; do echo Success! >> /output/output.txt; sleep 5; done']
- name: busybox2
image: busybox
command: ['sh', '-c', 'while true; do cat /input/output.txt; sleep 5; done']
Set up the volumes, again at the same level as containers with an emptyDir volume that only exists to share data between two containers in a simple way:
volumes:
- name: shared-vol
emptyDir: {}
Mount that volume between the two containers by adding the following lines under command for the busybox1 container:
volumeMounts:
- name: shared-vol
mountPath: /output
For the busybox2 container, add the following lines to mount the same volume under command to complete creating the shared file:
volumeMounts:
- name: shared-vol
mountPath: /input
The complete file
Finish creating the multi-container Pod using kubectl create -f shared-data-pod.yml.
apiVersion: v1
kind: Pod
metadata:
name: shared-data-pod
spec:
containers:
- name: busybox1
image: busybox
command: ['sh', '-c', 'while true; do echo Success! >> /output/output.txt; sleep 5; done']
volumeMounts:
- name: shared-vol
mountPath: /output
- name: busybox2
image: busybox
command: ['sh', '-c', 'while true; do cat /input/output.txt; sleep 5; done']
volumeMounts:
- name: shared-vol
mountPath: /input
volumes:
- name: shared-vol
emptyDir: {}
And you can now apply the YAML file.
Cheers
Osama
Kubernetes Services are a great way to combine Kubernetes networking with the dynamic and often automated nature of Kubernetes applications. In this lab, you will use Services to expose existing Kubernetes Pods. This will allow you to practice your skills with Kubernetes Services.
apiVersion: v1
kind: Service
metadata:
name: user-db-svc
spec:
type: ClusterIP
selector:
app: user-db
ports:
- protocol: TCP
port: 80
targetPort: 80
apiVersion: v1
kind: Service
metadata:
name: web-frontend-svc
spec:
type: NodePort
selector:
app: web-frontend
ports:
- protocol: TCP
port: 80
targetPort: 80
nodePort: 30080
Static pods are a great way to run a pod on a single node without the involvement of the Kubernetes control plane. In this lab, you will have a chance to exercise your knowledge of static pods by creating them in an existing cluster.
sudo vi /etc/kubernetes/manifests/example.yml
Anything under this path will be managed by kubelet.
Add the following line
apiVersion: v1
kind: Pod
metadata:
name: beebox-diagnostic
spec:
containers:
- name: nginx
image: nginx:1.14
ports:
- containerPort: 80
Restart kubelet to start the static pod:
sudo systemctl restart kubelet
Now if you try to delete it will work because it’s managed by kubelet.
Cheers
Osama