APPLICATIONS RUNNING ON KUBERNETES

Kategori: HAFİF BİLGİLER | 0

Bookstack Application Install On Kubernetes

INFO: This work has been tried on one node. This application running kubernetes master node. If you are going to try this on a cluster with multiple nodes, you have to open the mount folders on that worker node. You need to use node selector to determine which node to pod will be created on. I will not telling node selector issue here.

If you want bookstack applications running on kubernetes you should follow the below steps. If you have not a docker user, you must create a docker user. Also you have a docker group you adding docker user in docker group.

For create a docker user;

useradd docker

For adding docker user in docker group;

useradd -g docker docker

After above steps you save the id docker user because you will use in yaml file.

id docker
List of Docker User and Group ID

Step1:
You must create new deployment yaml file and edit some below. I wrote the yaml file there, but we will use the this file after all steps because we will must get ip address.

vim bookstack.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bookstack
  labels:
    app: bookstack
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bookstack
  template:
    metadata:
      labels:
        app: bookstack
    spec:
      containers:
      - name: bookstack
        image: linuxserver/bookstack
        ports:
        - containerPort: 80
        env:
        - name: PUID
          value: "1000"
        - name: PGID
          value: "986"
        - name: DB_HOST
          value: "bookstack_db"
        - name: DB_USER
          value: "bookstack"
        - name: DB_PASS
          value: "bookstack"
        - name: DB_DATABASE
          value: "bookstack"          
        volumeMounts:
        - mountPath: "/config"
          name: bokstackvolume
      volumes:
      - name: bokstackvolume
        persistentVolumeClaim:
          claimName: bookstackpvc
   

If you should done it, you should wait to end all steps . Because you must create a persistentet volume and volume claim of kubernetes resources and all items.Then after you should take db pod IP address and write in deployment yaml file. For this you should follow the below steps.

Step2:

vim bokstackpv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: bookstackpv
  labels:
    type: local
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/bookstack"

Then after:

mkdir /opt/bookstack
kubectl create -f bookstackpv.yaml
kubectl get pv
List of Persistent Volume

Then after;

vim bookstackpvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bookstackpvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
kubectl create -f bookstackpvc.yaml

This pvc resorces otomaticly bounded on pv resorces.

kubectl get pvc
List of Persistent Volume Claim

Then after you create yaml file for bookstack database. Following below steps;

Step3:

vim bookstackdb.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bookstackdb
  labels:
    app: bookstackdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bookstackdb
  template:
    metadata:
      labels:
        app: bookstackdb
    spec:
      containers:
      - name: bookstackdb
        image: linuxserver/mariadb
        ports:
        - containerPort: 3306
        env:
        - name: PUID
          value: "1001"
        - name: PGID
          value: "986"
        - name: MYSQL_ROOT_PASSWORD
          value: "bookstack"
        - name: MYSQL_DATABASE
          value: "bookstack"
        - name: MYSQL_USER
          value: "bookstack"  
        - name: MYSQL_PASSWORD
          value: "bookstack"
        - name: TZ
          value: "Europe/London"   
        volumeMounts:
        - mountPath: "/config"
          name: bokstackdbvolume
      volumes:
      - name: bokstackdbvolume
        persistentVolumeClaim:
          claimName: bookstackdbpvc

Then after you must create yaml file for db pv and pvc as below.

Step4:

vim bookstackdbpv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: bookstackdbpv
  labels:
    type: local
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/bookstackdb"
mkdir /opt/bookstackdb
kubectl create -f bookstackdbpv.yaml
kubectl get pv
List Of Persistent Volume
vim bookstackdbpvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: bookstackdbpvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
kubectl create -f bookstackdbpvc.yaml
List Of Persistent Volume Claim

Then after you should create a bookstackdb deployment resorces of kubernetes.

kubectl create -f bookstackdb.yaml

Then after, let’s list of the pods and look at the status of the pods;

kubectl get pods
List Of Pods
kubectl logs bookstackdb-5d86557d85-p2gdf
Logs Of Pods

The db deployment and pod was successfuly as the above picture. Then after we must list in detail pod for take ip adress.

kubectl get pods -o wide 
List of Pods With Details

Step5:
Let’s edit the bokstack deployment yaml file and add above ip address.

vim bookstack.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: bookstack
  labels:
    app: bookstack
spec:
  replicas: 1
  selector:
    matchLabels:
      app: bookstack
  template:
    metadata:
      labels:
        app: bookstack
    spec:
      containers:
      - name: bookstack
        image: linuxserver/bookstack
        ports:
        - containerPort: 80
        env:
        - name: PUID
          value: "1001"
        - name: PGID
          value: "986"
        - name: DB_HOST
          value: "10.244.0.86"
        - name: DB_USER
          value: "bookstack"
        - name: DB_PASS
          value: "bookstack"
        - name: DB_DATABASE
          value: "bookstack"
        volumeMounts:
        - mountPath: "/config"
          name: bokstackvolume
      volumes:
      - name: bokstackvolume
        persistentVolumeClaim:
          claimName: bookstackpvc

Step6:
You must create service for connect to bookstack application. I used nodeport here. You must stop the firewalld or adding port in firewall.

systemctl stop firewalld
vim bookstacksvc.yaml
apiVersion: v1
kind: Service
metadata:
  name: bookstack
  labels:
    app: bookstack
spec:
  ports:
  - port: 80
    protocol: TCP
  selector:
    app: bookstack
  type: NodePort
kubectl create -f bookstacksvc.yaml
kubectl get svc
List Of Kubernetes Service

We can connect through the browser now.

Connect of Bookstack

Default Login email and password;
Email: admin@admin.com
Password: password

Bookstack Applicaiton Was Succesfull

GITLAB INSTALL ON KUBERNETES

Gitlab installation will be explained under this topic. This installation did on kubernetes master node. Also if you have multiple node you should use node selector and you must create mount folder under selected node. We will use persistent volume, persistent volume claim, deployment and service resources. Also we will use nginx reverse proxy and self signed certificate, for connect gitlab application after created all kubernetes resources.
You must follow below commands;

Step1:

Create persistent volume kubernetes resources  so we should do create yaml file and create, but before this step you must create volume folders under node,

mkdir -p /opt/gitlab/logs /opt/gitlab/data /opt/gitlab/config
vim gitlabpv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlabcnfgpv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/gitlab/config"
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlablgspv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/gitlab/logs"
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: gitlabdtpv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/gitlab/data"
kubectl create -f gitlabpv.yaml

Step2:
Create persistent volume claim kubernetes resources;

vim gitlabpvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlabcnfpvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlablgspvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: gitlabdtpvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
kubectl create -f gitlabpvc.yaml

Step3:
Create deployment for gitlab applicaiton;

vim gitlab.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab
  labels:
    app: gitlab
spec:
  replicas: 1
  selector:
    matchLabels:
      app: gitlab
  template:
    metadata:
      labels:
        app: gitlab
    spec:
      containers:
      - name: gitlab
        image: gitlab/gitlab-ee:latest
        ports:
        - name: http
          containerPort: 80
        - name: https
          containerPort: 443
        - name: ssh
          containerPort: 22
        volumeMounts:
        - mountPath: "/etc/gitlab"
          name: gitlabconfig
        - mountPath: "/var/log/gitlab"
          name: gitlablogs
        - mountPath: "/var/opt/gitlab"
          name: gitlabdata
      volumes:
      - name: gitlabconfig
        persistentVolumeClaim:
          claimName: gitlabcnfpvc
      - name: gitlablogs
        persistentVolumeClaim:
          claimName: gitlablgspvc
      - name: gitlabdata
        persistentVolumeClaim:
          claimName: gitlabdtpvc

Step4:
Create kubernetes services for connect gitlab application;

If I find time, I will continued write.

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir