Prerequisite: 3 Vms ubuntu in Aws 1 machine GitLab runner is already running Step 1: On All the machine install kubernetes agent and comm...
Prerequisite:
3 Vms ubuntu in Aws
1 machine GitLab runner is already running
Step 1: On All the machine install kubernetes agent and common components
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
sudo apt-get update
apt install -qq -y kubeadm=1.21.0-00 kubelet=1.21.0-00 kubectl=1.21.0-00
sudo apt-mark hold kubelet kubeadm kubectl
Step 2: Run below commands on Gitlab server machine
- kubeadm init --apiserver-advertise-address=<<Master ServerIP>> --pod-network-cidr=192.168.0.0/16
- mkdir -p $HOME/.kube
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
- kubectl create -f https://docs.projectcalico.org/v3.18/manifests/calico.yaml
Step 3: Install helm on Master server only.
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
Create Deployment
helm create deploy
cd deploy/templates
rm * -ifr
vi deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: capstone-deploy
labels:
app: capstone-app
spec:
replicas: 3
template:
metadata:
labels:
app: capstone-app
spec:
containers:
- name: container
image: nginx:1.7.9
ports:
- containerPort: 80
selector:
matchLabels:
app: capstone-app
Create a Nodeport service file service.yaml
apiVersion: v1
kind: Service
metadata:
name: capstone-service
labels:
app: capstone-app
spec:
selector:
app: capstone-app
type: NodePort
ports:
- nodePort: 31111
port: 80
targetPort: 80
Save the file
cd ../..
helm install capstonecharts deploy'
helm list
helm uninstall capstonecharts
COMMENTS