From bbfe39e0766ce01f35aad45ce7c869b10d0979a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Thu, 31 Jan 2019 23:24:20 +0100 Subject: [PATCH] Use folders for groups of YAML files This keeps our configuration DRY and helps us to save keystrokes. --- README.md | 23 ++++++++--------- config/.gitignore | 1 + .../backend.yml | 0 .../neo4j-configmap.yaml => config/neo4j.yml | 0 staging/web-configmap.yaml => config/web.yml | 0 ...e.yaml => db-migration-worker.template.yml | 0 .../backend.yml | 0 .../db-migration-worker.yml | 0 .../neo4j.yml | 0 .../web.yml | 0 dummies/backend-service.yaml | 13 ---------- dummies/do-loadbalancer.yaml | 12 --------- dummies/ingress-backend.yaml | 15 ----------- dummies/nginx.yaml | 22 ---------------- dummies/web-service.yaml | 13 ---------- namespace-staging.json | 10 -------- namespace-staging.yml | 6 +++++ ...rets.yaml.template => secrets.template.yml | 0 services/backend.yml | 2 -- services/neo4j.yml | 2 -- services/web.yml | 1 - services/webapp.yml | 21 ---------------- staging/.gitignore | 1 - staging/volumes/mongo-export-claim.yaml | 11 -------- staging/volumes/mongo-export-volume.yaml | 12 --------- staging/volumes/ssh-keys-volume-claim.yml | 11 -------- staging/volumes/ssh-keys-volume.yaml | 12 --------- staging/volumes/uploads-claim.yaml | 11 -------- staging/volumes/uploads-volume.yaml | 12 --------- volumes/mongo-export.yml | 25 +++++++++++++++++++ volumes/ssh-keys.yml | 25 +++++++++++++++++++ volumes/uploads.yml | 25 +++++++++++++++++++ 32 files changed, 93 insertions(+), 193 deletions(-) create mode 100644 config/.gitignore rename staging/backend-configmap.yaml => config/backend.yml (100%) rename staging/neo4j-configmap.yaml => config/neo4j.yml (100%) rename staging/web-configmap.yaml => config/web.yml (100%) rename staging/db-migration-worker-configmap.template.yaml => db-migration-worker.template.yml (100%) rename staging/backend-deployment.yaml => deployments/backend.yml (100%) rename staging/db-migration-worker-deployment.yaml => deployments/db-migration-worker.yml (100%) rename staging/neo4j-deployment.yaml => deployments/neo4j.yml (100%) rename staging/web-deployment.yaml => deployments/web.yml (100%) delete mode 100644 dummies/backend-service.yaml delete mode 100644 dummies/do-loadbalancer.yaml delete mode 100644 dummies/ingress-backend.yaml delete mode 100644 dummies/nginx.yaml delete mode 100644 dummies/web-service.yaml delete mode 100644 namespace-staging.json create mode 100644 namespace-staging.yml rename staging/secrets.yaml.template => secrets.template.yml (100%) delete mode 100644 services/webapp.yml delete mode 100644 staging/.gitignore delete mode 100644 staging/volumes/mongo-export-claim.yaml delete mode 100644 staging/volumes/mongo-export-volume.yaml delete mode 100644 staging/volumes/ssh-keys-volume-claim.yml delete mode 100644 staging/volumes/ssh-keys-volume.yaml delete mode 100644 staging/volumes/uploads-claim.yaml delete mode 100644 staging/volumes/uploads-volume.yaml create mode 100644 volumes/mongo-export.yml create mode 100644 volumes/ssh-keys.yml create mode 100644 volumes/uploads.yml diff --git a/README.md b/README.md index 00ddea2d4..48d644622 100644 --- a/README.md +++ b/README.md @@ -19,35 +19,33 @@ There are many Kubernetes distributions, but if you're just getting started, Min ## Create a namespace locally ```shell -kubectl create -f namespace-staging.json +kubectl create -f namespace-staging.yml ``` ## Change config maps according to your needs ```shell -cd ./staging +cd config/ cp db-migration-worker-configmap.template.yaml db-migration-worker-configmap.yaml # edit all variables according to the setup of the remote legacy server +cd .. ``` ## Apply the config map to staging namespace ```shell -cd ./staging -kubectl apply -f neo4j-configmap.yaml -f backend-configmap.yaml -f web-configmap.yaml -f db-migration-worker-configmap.yaml +kubectl apply -f config/ ``` ## Setup secrets and deploy themn ```shell -cd ./staging cp secrets.yaml.template secrets.yaml # change all vars as needed and deploy it afterwards kubectl apply -f secrets.yaml ``` -## Deploy the app +## Create volumes and deployments ```shell -cd ./staging -kubectl apply -f ./volumes -kubectl apply -f neo4j-deployment.yaml -f backend-deployment.yaml -f web-deployment.yaml -f db-migration-worker-deployment.yaml +kubectl apply -f volumes/ +kubectl apply -f deployments/ ``` This can take a while. Sit back and relax and have a look into your minikube dashboard: @@ -59,7 +57,7 @@ Wait until all pods turn green and they don't show a warning `Waiting: Container ## Expose the services ```shell -kubectl create -f services/ +kubectl apply -f services/ ``` ## Access the service @@ -77,11 +75,12 @@ Copy your private ssh key and the `.known-hosts` file of your remote legacy serv # check the corresponding db-migration-worker pod kubectl --namespace=staging get pods # change below -kubectl cp path/to/your/ssh/keys/folder staging/nitro-db-migration-worker-:/root/ +kubectl cp path/to/your/ssh/keys/.ssh staging/nitro-db-migration-worker-:/root/ ``` Run the migration: ```shell -# change below +# change below kubectl --namespace=staging exec -it nitro-db-migration-worker- ./import.sh +kubectl --namespace=staging exec -it nitro-neo4j- ./import/import.sh ``` diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 000000000..6fe22561d --- /dev/null +++ b/config/.gitignore @@ -0,0 +1 @@ +db-migration-worker.yml diff --git a/staging/backend-configmap.yaml b/config/backend.yml similarity index 100% rename from staging/backend-configmap.yaml rename to config/backend.yml diff --git a/staging/neo4j-configmap.yaml b/config/neo4j.yml similarity index 100% rename from staging/neo4j-configmap.yaml rename to config/neo4j.yml diff --git a/staging/web-configmap.yaml b/config/web.yml similarity index 100% rename from staging/web-configmap.yaml rename to config/web.yml diff --git a/staging/db-migration-worker-configmap.template.yaml b/db-migration-worker.template.yml similarity index 100% rename from staging/db-migration-worker-configmap.template.yaml rename to db-migration-worker.template.yml diff --git a/staging/backend-deployment.yaml b/deployments/backend.yml similarity index 100% rename from staging/backend-deployment.yaml rename to deployments/backend.yml diff --git a/staging/db-migration-worker-deployment.yaml b/deployments/db-migration-worker.yml similarity index 100% rename from staging/db-migration-worker-deployment.yaml rename to deployments/db-migration-worker.yml diff --git a/staging/neo4j-deployment.yaml b/deployments/neo4j.yml similarity index 100% rename from staging/neo4j-deployment.yaml rename to deployments/neo4j.yml diff --git a/staging/web-deployment.yaml b/deployments/web.yml similarity index 100% rename from staging/web-deployment.yaml rename to deployments/web.yml diff --git a/dummies/backend-service.yaml b/dummies/backend-service.yaml deleted file mode 100644 index 48fffbc24..000000000 --- a/dummies/backend-service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - labels: - k8s-app: nitro-backend - name: nitro-backend - namespace: staging -spec: - ports: - - port: 4000 - targetPort: 4000 - selector: - k8s-app: nitro-backend diff --git a/dummies/do-loadbalancer.yaml b/dummies/do-loadbalancer.yaml deleted file mode 100644 index 9c700e082..000000000 --- a/dummies/do-loadbalancer.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: sample-load-balancer - namespace: staging -spec: - type: LoadBalancer - ports: - - protocol: TCP - port: 80 - targetPort: 80 - name: http diff --git a/dummies/ingress-backend.yaml b/dummies/ingress-backend.yaml deleted file mode 100644 index 0640b49fd..000000000 --- a/dummies/ingress-backend.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: backend-ingress - namespace: staging - annotations: - nginx.ingress.kubernetes.io/rewrite-target: / -spec: - rules: - - http: - paths: - - path: / - backend: - serviceName: backend - servicePort: 4000 diff --git a/dummies/nginx.yaml b/dummies/nginx.yaml deleted file mode 100644 index 1f5136b4b..000000000 --- a/dummies/nginx.yaml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: ingress-nginx - namespace: staging - labels: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx -spec: - type: NodePort - ports: - - name: http - port: 80 - targetPort: 80 - protocol: TCP - - name: https - port: 443 - targetPort: 443 - protocol: TCP - selector: - app.kubernetes.io/name: ingress-nginx - app.kubernetes.io/part-of: ingress-nginx diff --git a/dummies/web-service.yaml b/dummies/web-service.yaml deleted file mode 100644 index 847ba3c05..000000000 --- a/dummies/web-service.yaml +++ /dev/null @@ -1,13 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - labels: - k8s-app: nitro-web - name: nitro-web - namespace: staging -spec: - ports: - - port: 3000 - targetPort: 3000 - selector: - k8s-app: nitro-web diff --git a/namespace-staging.json b/namespace-staging.json deleted file mode 100644 index 6b71bc772..000000000 --- a/namespace-staging.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "staging", - "labels": { - "name": "staging" - } - } -} \ No newline at end of file diff --git a/namespace-staging.yml b/namespace-staging.yml new file mode 100644 index 000000000..d63b4e0f9 --- /dev/null +++ b/namespace-staging.yml @@ -0,0 +1,6 @@ +kind: Namespace +apiVersion: v1 +metadata: + name: staging + labels: + name: staging diff --git a/staging/secrets.yaml.template b/secrets.template.yml similarity index 100% rename from staging/secrets.yaml.template rename to secrets.template.yml diff --git a/services/backend.yml b/services/backend.yml index 0d4246275..d4f01286a 100644 --- a/services/backend.yml +++ b/services/backend.yml @@ -8,10 +8,8 @@ metadata: spec: ports: - name: web - protocol: TCP port: 4000 targetPort: 4000 - nodePort: 32612 selector: workload.user.cattle.io/workloadselector: deployment-staging-backend type: LoadBalancer diff --git a/services/neo4j.yml b/services/neo4j.yml index 681ba2e40..e071f78bb 100644 --- a/services/neo4j.yml +++ b/services/neo4j.yml @@ -10,11 +10,9 @@ spec: workload.user.cattle.io/workloadselector: deployment-staging-neo4j ports: - name: bolt - protocol: TCP port: 7687 targetPort: 7687 - name: web - protocol: TCP port: 7474 targetPort: 7474 type: LoadBalancer diff --git a/services/web.yml b/services/web.yml index a46e27dea..e1bd542f1 100644 --- a/services/web.yml +++ b/services/web.yml @@ -8,7 +8,6 @@ metadata: spec: ports: - name: web - protocol: "TCP" port: 3000 targetPort: 3000 selector: diff --git a/services/webapp.yml b/services/webapp.yml deleted file mode 100644 index a46e27dea..000000000 --- a/services/webapp.yml +++ /dev/null @@ -1,21 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: nitro-web - namespace: staging - labels: - workload.user.cattle.io/workloadselector: deployment-staging-web -spec: - ports: - - name: web - protocol: "TCP" - port: 3000 - targetPort: 3000 - selector: - workload.user.cattle.io/workloadselector: deployment-staging-web - type: LoadBalancer - sessionAffinity: None - externalTrafficPolicy: Cluster -status: - loadBalancer: {} - diff --git a/staging/.gitignore b/staging/.gitignore deleted file mode 100644 index d9c5e61bf..000000000 --- a/staging/.gitignore +++ /dev/null @@ -1 +0,0 @@ -db-migration-worker-configmap.yaml diff --git a/staging/volumes/mongo-export-claim.yaml b/staging/volumes/mongo-export-claim.yaml deleted file mode 100644 index 1c91996db..000000000 --- a/staging/volumes/mongo-export-claim.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: mongo-export-claim - namespace: staging -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 1Gi diff --git a/staging/volumes/mongo-export-volume.yaml b/staging/volumes/mongo-export-volume.yaml deleted file mode 100644 index 945c28765..000000000 --- a/staging/volumes/mongo-export-volume.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: mongo-export-volume - namespace: staging -spec: - accessModes: - - ReadWriteMany - capacity: - storage: 1Gi - hostPath: - path: /data/shared/mongo-exports/ diff --git a/staging/volumes/ssh-keys-volume-claim.yml b/staging/volumes/ssh-keys-volume-claim.yml deleted file mode 100644 index 30191a500..000000000 --- a/staging/volumes/ssh-keys-volume-claim.yml +++ /dev/null @@ -1,11 +0,0 @@ -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: ssh-keys-claim - namespace: staging -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1Mi diff --git a/staging/volumes/ssh-keys-volume.yaml b/staging/volumes/ssh-keys-volume.yaml deleted file mode 100644 index 9c0353b74..000000000 --- a/staging/volumes/ssh-keys-volume.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: ssh-keys-volume - namespace: staging -spec: - accessModes: - - ReadWriteOnce - capacity: - storage: 1Mi - hostPath: - path: /data/pv0001/ diff --git a/staging/volumes/uploads-claim.yaml b/staging/volumes/uploads-claim.yaml deleted file mode 100644 index c1b11ed4e..000000000 --- a/staging/volumes/uploads-claim.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: PersistentVolumeClaim -apiVersion: v1 -metadata: - name: uploads-claim - namespace: staging -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 8Gi diff --git a/staging/volumes/uploads-volume.yaml b/staging/volumes/uploads-volume.yaml deleted file mode 100644 index 4600a76a4..000000000 --- a/staging/volumes/uploads-volume.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: uploads-volume - namespace: staging -spec: - accessModes: - - ReadWriteMany - capacity: - storage: 8Gi - hostPath: - path: /data/shared/uploads/ diff --git a/volumes/mongo-export.yml b/volumes/mongo-export.yml new file mode 100644 index 000000000..a5ef064cc --- /dev/null +++ b/volumes/mongo-export.yml @@ -0,0 +1,25 @@ +--- + kind: PersistentVolume + apiVersion: v1 + metadata: + name: mongo-export-volume + namespace: staging + spec: + accessModes: + - ReadWriteMany + capacity: + storage: 1Gi + hostPath: + path: /data/shared/mongo-exports/ +--- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: mongo-export-claim + namespace: staging + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi diff --git a/volumes/ssh-keys.yml b/volumes/ssh-keys.yml new file mode 100644 index 000000000..4ffd83e80 --- /dev/null +++ b/volumes/ssh-keys.yml @@ -0,0 +1,25 @@ +--- + apiVersion: v1 + kind: PersistentVolume + metadata: + name: ssh-keys-volume + namespace: staging + spec: + accessModes: + - ReadWriteOnce + capacity: + storage: 1Mi + hostPath: + path: /data/pv0001/ +--- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: ssh-keys-claim + namespace: staging + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Mi diff --git a/volumes/uploads.yml b/volumes/uploads.yml new file mode 100644 index 000000000..34b600aab --- /dev/null +++ b/volumes/uploads.yml @@ -0,0 +1,25 @@ +--- + apiVersion: v1 + kind: PersistentVolume + metadata: + name: uploads-volume + namespace: staging + spec: + accessModes: + - ReadWriteMany + capacity: + storage: 8Gi + hostPath: + path: /data/shared/uploads/ +--- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: uploads-claim + namespace: staging + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 8Gi