aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4')
-rw-r--r--moonv4/kubernetes/README.md50
-rw-r--r--moonv4/kubernetes/conf/password_moon.txt1
-rw-r--r--moonv4/kubernetes/conf/password_root.txt1
-rw-r--r--moonv4/kubernetes/conf/ports.conf20
-rw-r--r--moonv4/kubernetes/init_k8s.sh30
-rw-r--r--moonv4/kubernetes/start_moon.sh30
-rw-r--r--moonv4/kubernetes/templates/consul.yaml33
-rw-r--r--moonv4/kubernetes/templates/db.yaml82
-rw-r--r--moonv4/kubernetes/templates/keystone.yaml34
-rw-r--r--moonv4/kubernetes/templates/moon_configuration.yaml23
-rw-r--r--moonv4/kubernetes/templates/moon_gui.yaml33
-rw-r--r--moonv4/kubernetes/templates/moon_manager.yaml33
-rw-r--r--moonv4/kubernetes/templates/moon_orchestrator.yaml40
13 files changed, 410 insertions, 0 deletions
diff --git a/moonv4/kubernetes/README.md b/moonv4/kubernetes/README.md
new file mode 100644
index 00000000..04d54924
--- /dev/null
+++ b/moonv4/kubernetes/README.md
@@ -0,0 +1,50 @@
+
+# Installation
+
+Choose the right deployment:
+
+## Minikube installation
+
+```bash
+curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
+chmod +x ./kubectl
+sudo mv ./kubectl /usr/local/bin/kubectl
+curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.21.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
+```
+
+## Kubeadm installation
+
+see: https://kubernetes.io/docs/setup/independent/install-kubeadm/
+
+```bash
+apt-get update && apt-get install -y apt-transport-https
+curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
+cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
+deb http://apt.kubernetes.io/ kubernetes-xenial main
+EOF
+apt-get update
+apt-get install -y kubelet kubeadm kubectl
+```
+
+# Platform
+
+## Creation
+
+Execute the script : init_k8s.sh
+
+```bash
+sudo bash init_k8s.sh
+watch kubectl get po --namespace=kube-system
+```
+
+Wait until all pods are in "Running" state (crtl-c to stop the watch command)
+
+## Execution
+
+Execute the script : start_moon.sh
+
+```bash
+sudo bash start_moon.sh
+watch kubectl get po --namespace=moon
+```
+
diff --git a/moonv4/kubernetes/conf/password_moon.txt b/moonv4/kubernetes/conf/password_moon.txt
new file mode 100644
index 00000000..bb9bcf7d
--- /dev/null
+++ b/moonv4/kubernetes/conf/password_moon.txt
@@ -0,0 +1 @@
+p4sswOrd1 \ No newline at end of file
diff --git a/moonv4/kubernetes/conf/password_root.txt b/moonv4/kubernetes/conf/password_root.txt
new file mode 100644
index 00000000..bb9bcf7d
--- /dev/null
+++ b/moonv4/kubernetes/conf/password_root.txt
@@ -0,0 +1 @@
+p4sswOrd1 \ No newline at end of file
diff --git a/moonv4/kubernetes/conf/ports.conf b/moonv4/kubernetes/conf/ports.conf
new file mode 100644
index 00000000..d1b12aac
--- /dev/null
+++ b/moonv4/kubernetes/conf/ports.conf
@@ -0,0 +1,20 @@
+manager:
+ port: 8082
+ kport: 30001
+gui:
+ port: 3000
+ kport: 30002
+orchestrator:
+ port: 8083
+ kport: 30003
+
+consul:
+ port: 8500
+ kport: 30005
+keystone:
+ port: 5000
+ kport: 30006
+
+wrapper:
+ port: 8080
+ kport: 30010
diff --git a/moonv4/kubernetes/init_k8s.sh b/moonv4/kubernetes/init_k8s.sh
new file mode 100644
index 00000000..a0d02a95
--- /dev/null
+++ b/moonv4/kubernetes/init_k8s.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+set -x
+
+sudo kubeadm reset
+
+sudo swapoff -a
+
+#sudo kubeadm init --pod-network-cidr=192.168.0.0/16
+sudo kubeadm init --pod-network-cidr=10.244.0.0/16
+
+mkdir -p $HOME/.kube
+sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
+sudo chown $(id -u):$(id -g) $HOME/.kube/config
+
+#kubectl apply -f http://docs.projectcalico.org/v2.4/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml
+kubectl apply -f https://raw.githubusercontent.com/projectcalico/canal/master/k8s-install/1.6/rbac.yaml
+kubectl apply -f https://raw.githubusercontent.com/projectcalico/canal/master/k8s-install/1.6/canal.yaml
+
+kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
+
+kubectl taint nodes --all node-role.kubernetes.io/master-
+
+kubectl proxy&
+sleep 5
+echo =========================================
+kubectl get po --namespace=kube-system
+echo =========================================
+
+
diff --git a/moonv4/kubernetes/start_moon.sh b/moonv4/kubernetes/start_moon.sh
new file mode 100644
index 00000000..9900f1ec
--- /dev/null
+++ b/moonv4/kubernetes/start_moon.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+set -x
+
+kubectl create namespace moon
+kubectl create configmap moon-config --from-file conf/moon.conf -n moon
+kubectl create configmap config --from-file ~/.kube/config -n moon
+kubectl create secret generic mysql-root-pass --from-file=kubernetes/conf/password_root.txt -n moon
+kubectl create secret generic mysql-pass --from-file=kubernetes/conf/password_moon.txt -n moon
+
+kubectl create -n moon -f kubernetes/templates/consul.yaml
+kubectl create -n moon -f kubernetes/templates/db.yaml
+kubectl create -n moon -f kubernetes/templates/keystone.yaml
+
+echo =========================================
+kubectl get pods -n moon
+echo =========================================
+
+kubectl create -n moon -f kubernetes/templates/moon_configuration.yaml
+
+echo Waiting for jobs moonforming
+sleep 5
+kubectl get jobs -n moon
+kubectl logs -n moon jobs/moonforming
+
+kubectl create -n moon -f kubernetes/templates/moon_manager.yaml
+kubectl create -n moon -f kubernetes/templates/moon_orchestrator.yaml
+kubectl create -n moon -f kubernetes/templates/moon_gui.yaml
+
+
diff --git a/moonv4/kubernetes/templates/consul.yaml b/moonv4/kubernetes/templates/consul.yaml
new file mode 100644
index 00000000..f0fb764e
--- /dev/null
+++ b/moonv4/kubernetes/templates/consul.yaml
@@ -0,0 +1,33 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ namespace: moon
+ name: consul
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: consul
+ spec:
+ hostname: consul
+ containers:
+ - name: consul
+ image: consul:latest
+ ports:
+ - containerPort: 8500
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: consul
+ namespace: moon
+spec:
+ ports:
+ - port: 8500
+ targetPort: 8500
+ nodePort: 30005
+ selector:
+ app: consul
+ type: NodePort
diff --git a/moonv4/kubernetes/templates/db.yaml b/moonv4/kubernetes/templates/db.yaml
new file mode 100644
index 00000000..0a62c077
--- /dev/null
+++ b/moonv4/kubernetes/templates/db.yaml
@@ -0,0 +1,82 @@
+#apiVersion: v1
+#kind: PersistentVolume
+#metadata:
+# name: local-pv-1
+# labels:
+# type: local
+#spec:
+# capacity:
+# storage: 5Gi
+# accessModes:
+# - ReadWriteOnce
+# hostPath:
+# path: /tmp/data/pv-1
+#---
+#
+#apiVersion: v1
+#kind: PersistentVolumeClaim
+#metadata:
+# name: mysql-pv-claim
+# labels:
+# platform: moon
+# app: db
+#spec:
+# accessModes:
+# - ReadWriteOnce
+# resources:
+# requests:
+# storage: 5Gi
+#---
+
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ name: db
+spec:
+ replicas: 1
+ strategy:
+ type: Recreate
+ template:
+ metadata:
+ labels:
+ app: db
+ spec:
+ containers:
+ - name: db
+ image: mysql:latest
+ env:
+ - name: MYSQL_DATABASE
+ value: "moon"
+ - name: MYSQL_USER
+ value: "moon"
+ - name: MYSQL_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: mysql-pass
+ key: password_moon.txt
+ - name: MYSQL_ROOT_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: mysql-root-pass
+ key: password_root.txt
+ ports:
+ - containerPort: 3306
+ name: mysql
+# volumeMounts:
+# - name: mysql-persistent-storage
+# mountPath: /var/lib/mysql
+# volumes:
+# - name: mysql-persistent-storage
+# persistentVolumeClaim:
+# claimName: mysql-pv-claim
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: db
+spec:
+ ports:
+ - port: 3306
+ selector:
+ app: db
+--- \ No newline at end of file
diff --git a/moonv4/kubernetes/templates/keystone.yaml b/moonv4/kubernetes/templates/keystone.yaml
new file mode 100644
index 00000000..84a51f7a
--- /dev/null
+++ b/moonv4/kubernetes/templates/keystone.yaml
@@ -0,0 +1,34 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ namespace: moon
+ name: keystone
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: keystone
+ spec:
+ hostname: keystone
+ containers:
+ - name: keystone
+ image: asteroide/keystone:mitaka
+ ports:
+ - containerPort: 35357
+ containerPort: 5000
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: keystone
+ namespace: moon
+spec:
+ ports:
+ - port: 5000
+ targetPort: 5000
+ nodePort: 30006
+ selector:
+ app: keystone
+ type: NodePort
diff --git a/moonv4/kubernetes/templates/moon_configuration.yaml b/moonv4/kubernetes/templates/moon_configuration.yaml
new file mode 100644
index 00000000..f3816932
--- /dev/null
+++ b/moonv4/kubernetes/templates/moon_configuration.yaml
@@ -0,0 +1,23 @@
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: moonforming
+ namespace: moon
+spec:
+ template:
+ metadata:
+ name: moonforming
+ spec:
+ containers:
+ - name: moonforming
+ image: asteroide/moonforming:v1.1
+ imagePullPolicy: Always
+ volumeMounts:
+ - name: config-volume
+ mountPath: /etc/moon
+ volumes:
+ - name: config-volume
+ configMap:
+ name: moon-config
+ restartPolicy: Never
+ #backoffLimit: 4 \ No newline at end of file
diff --git a/moonv4/kubernetes/templates/moon_gui.yaml b/moonv4/kubernetes/templates/moon_gui.yaml
new file mode 100644
index 00000000..732a3ce1
--- /dev/null
+++ b/moonv4/kubernetes/templates/moon_gui.yaml
@@ -0,0 +1,33 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ namespace: moon
+ name: gui
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: gui
+ spec:
+ hostname: gui
+ containers:
+ - name: gui
+ image: wukongsun/moon_gui:v4.1
+ ports:
+ - containerPort: 80
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: gui
+ namespace: moon
+spec:
+ ports:
+ - port: 80
+ targetPort: 80
+ nodePort: 30002
+ selector:
+ app: gui
+ type: NodePort
diff --git a/moonv4/kubernetes/templates/moon_manager.yaml b/moonv4/kubernetes/templates/moon_manager.yaml
new file mode 100644
index 00000000..9c3772d1
--- /dev/null
+++ b/moonv4/kubernetes/templates/moon_manager.yaml
@@ -0,0 +1,33 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ name: manager
+ namespace: moon
+spec:
+ replicas: 3
+ template:
+ metadata:
+ labels:
+ app: manager
+ spec:
+ hostname: manager
+ containers:
+ - name: manager
+ image: wukongsun/moon_manager:v4.3
+ ports:
+ - containerPort: 8082
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: manager
+ namespace: moon
+spec:
+ ports:
+ - port: 8082
+ targetPort: 8082
+ nodePort: 30001
+ selector:
+ app: manager
+ type: NodePort
diff --git a/moonv4/kubernetes/templates/moon_orchestrator.yaml b/moonv4/kubernetes/templates/moon_orchestrator.yaml
new file mode 100644
index 00000000..419f2d52
--- /dev/null
+++ b/moonv4/kubernetes/templates/moon_orchestrator.yaml
@@ -0,0 +1,40 @@
+apiVersion: apps/v1beta1
+kind: Deployment
+metadata:
+ namespace: moon
+ name: orchestrator
+spec:
+ replicas: 1
+ template:
+ metadata:
+ labels:
+ app: orchestrator
+ spec:
+ hostname: orchestrator
+ containers:
+ - name: orchestrator
+ image: wukongsun/moon_orchestrator:v4.3
+ ports:
+ - containerPort: 8083
+ volumeMounts:
+ - name: config-volume
+ mountPath: /root/.kube
+ volumes:
+ - name: config-volume
+ configMap:
+ name: config
+---
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: orchestrator
+ namespace: moon
+spec:
+ ports:
+ - port: 8083
+ targetPort: 8083
+ nodePort: 30003
+ selector:
+ app: orchestrator
+ type: NodePort