Skip to content

Instantly share code, notes, and snippets.

View SarasaGunawardhana's full-sized avatar
🎯
Focusing

Sarasa Gunawardhana SarasaGunawardhana

🎯
Focusing
View GitHub Profile
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
run: my-service-1
name: my-service-1
spec:
ports:
- name: https
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: my-service-1
name: my-service-1
spec:
replicas: 1
selector:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
replicas: 3
selector:
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx-01
name: nginx-01
spec:
containers:
- image: nginx
@SarasaGunawardhana
SarasaGunawardhana / docker-compose.yml
Created July 10, 2019 09:00
docker-compose.yml file for mongodb which expose port
#Sarasa Gunawardhana
version: "3.2"
services:
database:
image: mongodb:latest
environment:
- MONGO_DATA_DIR=/data/db
- MONGO_LOG_DIR=/dev/null
volumes:
- /data/db:/data/db
@SarasaGunawardhana
SarasaGunawardhana / kubernetesVSDocker.csv
Last active July 10, 2019 02:35
Advantages of kubernetes over Docker swarm
Docker Swarm Kubernetes
Developed by Docker Swarm Developed by Google
Has a smaller community compared to Kubernetes Has a vast Open source community
Has low fault tolerance Has high fault tolerance
Easy to set up and fits well into Docker ecosystem Requires heavy setup
Less extensive and less customizable More extensive and customizable
Features automated internal load balancing through any node in the cluster Enables load balancing when container pods are defined as services
Facilitates for quick container deployment and scaling even in very large clusters Provides strong guarantees to cluster states at the expense of speed
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
containers:
- image: nginx
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: v1.14.3
apiServer:
certSANs:
- "do-dev-master.sarasa-dev.com"
controlPlaneEndpoint: ""
networking:
podSubnet: 10.244.0.0/16
@SarasaGunawardhana
SarasaGunawardhana / kubeadm-config.yaml
Last active July 8, 2019 09:11
Kubeadm initiate configuration file
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration #you will need to ensure they match the version of the Kubernetes control plane of kubectl and kubeadm
kubernetesVersion: v1.14.3
apiServer:
certSANs: #Additional hostnames or IP addresses that should be added to the Subject Alternate Name section for the certificate that the API Server will use. If you expose the API Server through a load balancer and public DNS you could specify this with
- 127.0.0.1
- 157.180.200.132
- do-dev-master.sarasa-dev.com
extraArgs: # Add this section if you have setup default audit policy. if not, dont add this section
authorization-mode: Node,RBAC
@SarasaGunawardhana
SarasaGunawardhana / install-on-all-node.sh
Last active October 25, 2020 22:21
Prerequisites for Setup Kubenetes Cluster. You should install these things on each server.
#!/bin/bash
## Generic installation on all nodes
sysctl -w net.ipv4.ip_forward=1
sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
swapoff -a
sed -i '2s/^/#/' /etc/fstab