diff --git a/README.md b/README.md index 7b5ba30..0973d5a 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,12 @@ to explore ArgoCD and GitOps! | Application | Description | |-------------|-------------| -| [guestbook](guestbook/) | A hello word application | +| [guestbook](guestbook/) | A hello word guestbook application as plain YAML | | [ksonnet-guestbook](ksonnet-guestbook/) | The guestbook application as a ksonnet app | | [helm-guestbook](helm-guestbook/) | The guestbook application as a Helm chart | | [jsonnet-guestbook](jsonnet-guestbook/) | The guestbook application as a raw jsonnet | | [kustomize-guestbook](kustomize-guestbook/) | The guestbook application as a kustomize app | -| [pre-post-sync](pre-post-sync/) | Demonstrates ArgoCD PreSync and PostSync hooks | -| [blue-green-deploy](blue-green-deploy/) | Demonstrates an ArgoCD Sync hook which performs a blue/green deployment | +| [pre-post-sync](pre-post-sync/) | Demonstrates Argo CD PreSync and PostSync hooks | +| [blue-green-deploy](blue-green-deploy/) | Demonstrates an Argo CD Sync hook which performs a blue/green deployment | +| [blue-green-deploy-workflow](blue-green-deploy-workflow/) | Demonstrates an ArgoCD Sync hook which performs a blue/green deployment as an Argo Workflow | | [sock-shop](sock-shop/) | A microservices demo application (https://microservices-demo.github.io) | diff --git a/pre-post-sync/.gitignore b/blue-green-deploy-workflow/.gitignore similarity index 100% rename from pre-post-sync/.gitignore rename to blue-green-deploy-workflow/.gitignore diff --git a/pre-post-sync/app.yaml b/blue-green-deploy-workflow/app.yaml similarity index 86% rename from pre-post-sync/app.yaml rename to blue-green-deploy-workflow/app.yaml index a2e050f..3ece49c 100644 --- a/pre-post-sync/app.yaml +++ b/blue-green-deploy-workflow/app.yaml @@ -7,5 +7,5 @@ environments: k8sVersion: v1.10.0 path: default kind: ksonnet.io/app -name: pre-post-sync +name: blue-green-deploy-workflow version: 0.0.1 diff --git a/pre-post-sync/components/guestbook-ui.jsonnet b/blue-green-deploy-workflow/components/bg-guestbook.jsonnet similarity index 63% rename from pre-post-sync/components/guestbook-ui.jsonnet rename to blue-green-deploy-workflow/components/bg-guestbook.jsonnet index 27735d2..f6e83a6 100644 --- a/pre-post-sync/components/guestbook-ui.jsonnet +++ b/blue-green-deploy-workflow/components/bg-guestbook.jsonnet @@ -1,11 +1,14 @@ local env = std.extVar("__ksonnet/environments"); -local params = std.extVar("__ksonnet/params").components["guestbook-ui"]; +local params = std.extVar("__ksonnet/params").components["bg-guestbook"]; [ { "apiVersion": "v1", "kind": "Service", "metadata": { - "name": params.name + "name": params.name, + "annotations": { + "argocd.argoproj.io/hook": "Skip", + }, }, "spec": { "ports": [ @@ -24,7 +27,10 @@ local params = std.extVar("__ksonnet/params").components["guestbook-ui"]; "apiVersion": "apps/v1beta2", "kind": "Deployment", "metadata": { - "name": params.name + "name": params.name, + "annotations": { + "argocd.argoproj.io/hook": "Skip", + }, }, "spec": { "replicas": params.replicas, @@ -42,21 +48,13 @@ local params = std.extVar("__ksonnet/params").components["guestbook-ui"]; "spec": { "containers": [ { - "image": params.image, - "name": params.name, - "ports": [ + "image": params.image, + "name": params.name, + "ports": [ { "containerPort": params.containerPort } - ], - // dummy readiness probe to slow down the rollout for demo/testing - "readinessProbe": { - "exec": { - "command": [ "sh", "-c", "exit 0" ], - }, - "initialDelaySeconds": 10, - "periodSeconds": 30, - } + ] } ] } diff --git a/blue-green-deploy/components/bg-workflow.jsonnet b/blue-green-deploy-workflow/components/bg-workflow.jsonnet similarity index 100% rename from blue-green-deploy/components/bg-workflow.jsonnet rename to blue-green-deploy-workflow/components/bg-workflow.jsonnet diff --git a/pre-post-sync/components/params.libsonnet b/blue-green-deploy-workflow/components/params.libsonnet similarity index 75% rename from pre-post-sync/components/params.libsonnet rename to blue-green-deploy-workflow/components/params.libsonnet index 144e63d..4e14e47 100644 --- a/pre-post-sync/components/params.libsonnet +++ b/blue-green-deploy-workflow/components/params.libsonnet @@ -6,15 +6,14 @@ components: { // Component-level parameters, defined initially from 'ks prototype use ...' // Each object below should correspond to a component in the components/ directory - "guestbook-ui": { + "bg-guestbook": { containerPort: 80, image: "gcr.io/heptio-images/ks-guestbook-demo:0.2", - name: "pre-post-sync", - replicas: 1, + name: "bg-guestbook", + replicas: 3, servicePort: 80, - type: "ClusterIP", + type: "LoadBalancer", }, - "pre-sync-job": {}, - "post-sync-job": {}, + "bg-workflow": {}, }, } diff --git a/blue-green-deploy/components/wf/bluegreen.yaml b/blue-green-deploy-workflow/components/wf/bluegreen.yaml similarity index 88% rename from blue-green-deploy/components/wf/bluegreen.yaml rename to blue-green-deploy-workflow/components/wf/bluegreen.yaml index 3749fdf..27dce4a 100644 --- a/blue-green-deploy/components/wf/bluegreen.yaml +++ b/blue-green-deploy-workflow/components/wf/bluegreen.yaml @@ -81,8 +81,8 @@ spec: args: - kubectl get --export -o json deployment.apps/{{workflow.parameters.deployment-name}} > /original-deploy && jq -r '.metadata.name+="-blue" | - .spec.template.metadata.labels += (.spec.template.metadata.labels | to_entries | map(select(.key != "applications.argoproj.io/app-name")) | map(.value+="-blue") | from_entries) | - .spec.selector.matchLabels += (.spec.selector.matchLabels | to_entries | map(select(.key != "applications.argoproj.io/app-name")) | map(.value+="-blue") | from_entries)' + .spec.template.metadata.labels += (.spec.template.metadata.labels | to_entries | map(select(.key != "app.kubernetes.io/instance")) | map(.value+="-blue") | from_entries) | + .spec.selector.matchLabels += (.spec.selector.matchLabels | to_entries | map(select(.key != "app.kubernetes.io/instance")) | map(.value+="-blue") | from_entries)' /original-deploy > /cloned-deploy && cat /cloned-deploy && kubectl apply -o yaml -f /cloned-deploy @@ -103,12 +103,12 @@ spec: command: [sh, -c, -x] args: - cp /manifest /manifest-new && - APP_NAME=$(kubectl get -n default -f /manifest-new -o json | jq -r '.metadata.labels."applications.argoproj.io/app-name"') && + APP_NAME=$(kubectl get -f /manifest-new -o json | jq -r '.metadata.labels."app.kubernetes.io/instance"') && if [ "$APP_NAME" != "null" ]; then - jq -r --arg APP_NAME "$APP_NAME" '.metadata.labels."applications.argoproj.io/app-name" = $APP_NAME' /manifest-new > /manifest-new.tmp && + jq -r --arg APP_NAME "$APP_NAME" '.metadata.labels."app.kubernetes.io/instance" = $APP_NAME' /manifest-new > /manifest-new.tmp && mv /manifest-new.tmp /manifest-new && if [ "$(jq -r .spec.template.metadata.labels /manifest-new)" != "null" ]; then - jq -r --arg APP_NAME "$APP_NAME" '.spec.template.metadata.labels."applications.argoproj.io/app-name" = $APP_NAME' /manifest-new > /manifest-new.tmp && + jq -r --arg APP_NAME "$APP_NAME" '.spec.template.metadata.labels."app.kubernetes.io/instance" = $APP_NAME' /manifest-new > /manifest-new.tmp && mv /manifest-new.tmp /manifest-new ; fi ; fi && @@ -131,7 +131,7 @@ spec: image: argoproj/argoexec:v2.1.1 command: [sh, -c, -x] args: - - kubectl get -n default service {{workflow.parameters.service-name}} --export -o json > /original-svc && + - kubectl get service {{workflow.parameters.service-name}} --export -o json > /original-svc && jq '.spec.selector = (.spec.selector | with_entries(.value+="-blue"))' /original-svc > /blue-svc && kubectl apply -o yaml -f /blue-svc diff --git a/pre-post-sync/environments/base.libsonnet b/blue-green-deploy-workflow/environments/base.libsonnet similarity index 100% rename from pre-post-sync/environments/base.libsonnet rename to blue-green-deploy-workflow/environments/base.libsonnet diff --git a/pre-post-sync/environments/default/globals.libsonnet b/blue-green-deploy-workflow/environments/default/globals.libsonnet similarity index 100% rename from pre-post-sync/environments/default/globals.libsonnet rename to blue-green-deploy-workflow/environments/default/globals.libsonnet diff --git a/pre-post-sync/environments/default/main.jsonnet b/blue-green-deploy-workflow/environments/default/main.jsonnet similarity index 100% rename from pre-post-sync/environments/default/main.jsonnet rename to blue-green-deploy-workflow/environments/default/main.jsonnet diff --git a/pre-post-sync/environments/default/params.libsonnet b/blue-green-deploy-workflow/environments/default/params.libsonnet similarity index 100% rename from pre-post-sync/environments/default/params.libsonnet rename to blue-green-deploy-workflow/environments/default/params.libsonnet diff --git a/blue-green-deploy/app.yaml b/blue-green-deploy/app.yaml index 5178e12..3bf1f7d 100644 --- a/blue-green-deploy/app.yaml +++ b/blue-green-deploy/app.yaml @@ -1,11 +1,15 @@ -apiVersion: 0.1.0 +apiVersion: 0.3.0 environments: default: destination: - namespace: default + namespace: blue-green-deploy server: https://kubernetes.default.svc k8sVersion: v1.10.0 path: default kind: ksonnet.io/app name: blue-green-deploy +registries: + incubator: + protocol: github + uri: github.com/ksonnet/parts/tree/master/incubator version: 0.0.1 diff --git a/blue-green-deploy/blue-green.sh b/blue-green-deploy/blue-green.sh new file mode 100755 index 0000000..ac7d21b --- /dev/null +++ b/blue-green-deploy/blue-green.sh @@ -0,0 +1,71 @@ +#!bin/bash + +DEPLOYMENT_NAME=$(echo "${DEPLOY_MANIFEST}" | jq -r '.metadata.name') +SERVICE_NAME=$(echo "${SERVICE_MANIFEST}" | jq -r '.metadata.name') + +# 1. Check if the deployment exists. If it doesn't exist, this is the initial deployment and we +# can simply deploy without blue-green. Add the app label using jq +out=$(kubectl get --export -o json deployment.apps/${DEPLOYMENT_NAME} 2>&1) +if [ $? -ne 0 ]; then + if [[ "${out}" =~ "NotFound" ]] ; then + echo "Initial deployment" + echo ${DEPLOY_MANIFEST} | \ + jq ".metadata.labels += {\"app.kubernetes.io/instance\": \"${APPNAME}\"}" | \ + kubectl apply -o yaml -f - || exit 1 + echo ${SERVICE_MANIFEST} | \ + jq ".metadata.labels += {\"app.kubernetes.io/instance\": \"${APPNAME}\"}" | \ + kubectl apply -o yaml -f - || exit 1 + exit 0 + fi + echo "Failed to get deployment: ${out}" + exit 1 +fi +ORIGINAL_DEPLOY_MANIFEST=$out + +# 2. Clone the original, running deployment to a temporary deployment, with tweaks to its name and +# selectors. The jq command carries over all labels and selectors and appends the `-temp` suffix. +TMP_DEPLOYMENT_NAME="${DEPLOYMENT_NAME}-temp" +echo ${ORIGINAL_DEPLOY_MANIFEST} | jq -r '.metadata.name+="-temp" | + .spec.template.metadata.labels += (.spec.template.metadata.labels | to_entries | map(.value+="-temp") | from_entries) | + .spec.selector.matchLabels += (.spec.selector.matchLabels | to_entries | map(.value+="-temp") | from_entries)' | + kubectl apply -f - + +# 3. Wait for cloned deployment to become ready. +sleep 2 +echo "Waiting for successful rollout of new (temporary) deployment" +kubectl rollout status --watch=true deployments.apps/${TMP_DEPLOYMENT_NAME} || exit 1 +echo "Rollout of temporary deployment successful" + +# 4. Patch the service object such that all traffic is redirected to the cloned, temporary +# deployment. After this step, the original deployment will no longer be receiving traffic. +kubectl get service ${SERVICE_NAME} --export -o json | \ + jq '.spec.selector = (.spec.selector | with_entries(.value+="-temp"))' | + kubectl apply -f - || exit 1 +sleep 5 # Sleep slightly to allow iptables to get propagated to all nodes in the cluster + +# 5. Update the original deployment (now receiving no traffic) with the new manifest +echo "Updating original deployment" +echo ${DEPLOY_MANIFEST} | \ + jq ".metadata.labels += {\"app.kubernetes.io/instance\": \"${APPNAME}\"}" | \ + kubectl apply -f - || exit 1 + +# 6. Wait for the new deployment to become complete +sleep 2 +echo "Waiting for successful rollout of new deployment" +kubectl rollout status --watch=true deployments.apps/${DEPLOYMENT_NAME} || exit 1 +echo "Rollout of new deployment successful" + +# dummy wait step for demo purposes +echo "sleeping for 30 seconds" +sleep 30 + +# 7. Apply the new service object. Traffic will be redirected to the new version of the deployment +echo "Updating original service object" +echo ${SERVICE_MANIFEST} | \ + jq ".metadata.labels += {\"app.kubernetes.io/instance\": \"${APPNAME}\"}" | \ + kubectl apply -f - || exit 1 + +sleep 10 +# 8. Remove the cloned deployment, which is no longer receiving any traffic +echo "Deleting ephemeral deployment" +kubectl delete deployments/${TMP_DEPLOYMENT_NAME} --ignore-not-found=true || exit 1 diff --git a/blue-green-deploy/components/bg-guestbook.jsonnet b/blue-green-deploy/components/bg-guestbook.jsonnet index a059cc3..f6e83a6 100644 --- a/blue-green-deploy/components/bg-guestbook.jsonnet +++ b/blue-green-deploy/components/bg-guestbook.jsonnet @@ -51,9 +51,9 @@ local params = std.extVar("__ksonnet/params").components["bg-guestbook"]; "image": params.image, "name": params.name, "ports": [ - { - "containerPort": params.containerPort - } + { + "containerPort": params.containerPort + } ] } ] diff --git a/blue-green-deploy/components/bg-pod.jsonnet b/blue-green-deploy/components/bg-pod.jsonnet new file mode 100644 index 0000000..0f7365d --- /dev/null +++ b/blue-green-deploy/components/bg-pod.jsonnet @@ -0,0 +1,131 @@ +local bgGuestbook = std.extVar("__ksonnet/components")["bg-guestbook"]; +local bgGuestbookSvc = bgGuestbook[0]; +local bgGuestbookDeploy = bgGuestbook[1]; + +[ +{ + "apiVersion": "v1", + "kind": "Pod", + "metadata": { + "generateName": "blue-green-", + "annotations": { + "argocd.argoproj.io/hook": "Sync", + "deploy-manifest": std.manifestJson(bgGuestbookDeploy), + "svc-manifest": std.manifestJson(bgGuestbookSvc), + }, + }, + "spec": { + "serviceAccountName": "blue-green-sa", + "restartPolicy": "Never", + "containers": [ + { + "name": "blue-green", + "image": "argoproj/argoexec:latest", + "command": ["bash", "-c"], + "args": [" + curl -L -o /usr/local/bin/kubectl -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 /usr/local/bin/kubectl && + curl -sSL -o /usr/local/bin/blue-green.sh https://raw.githubusercontent.com/argoproj/argocd-example-apps/master/blue-green-deploy/blue-green.sh && + chmod +x /usr/local/bin/blue-green.sh && + blue-green.sh + "], + "env": [ + { + "name": "DEPLOY_MANIFEST", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.annotations['deploy-manifest']" + } + } + }, + { + "name": "SERVICE_MANIFEST", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.annotations['svc-manifest']" + } + } + }, + // NOTE: app.kubernetes.io/instance will get injected into the hook object + { + "name": "APPNAME", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.labels['app.kubernetes.io/instance']" + } + } + } + ] + } + ], + } +}, +// RBAC to allow the blue-green pod privileges to manipulate deployments and services +{ + "apiVersion": "v1", + "kind": "ServiceAccount", + "metadata": { + "name": "blue-green-sa" + } +}, +{ + "apiVersion": "rbac.authorization.k8s.io/v1", + "kind": "Role", + "metadata": { + "name": "blue-green-role" + }, + "rules": [ + { + "apiGroups": [ + "apps", + "extensions" + ], + "resources": [ + "deployments", + ], + "verbs": [ + "list", + "get", + "create", + "update", + "patch", + "delete", + ] + }, + { + "apiGroups": [ + "" + ], + "resources": [ + "services" + ], + "verbs": [ + "list", + "get", + "create", + "update", + "patch", + "delete", + ] + } + ] +}, +{ + "apiVersion": "rbac.authorization.k8s.io/v1", + "kind": "RoleBinding", + "metadata": { + "name": "blue-green-rolebinding" + }, + "roleRef": { + "apiGroup": "rbac.authorization.k8s.io", + "kind": "Role", + "name": "blue-green-role" + }, + "subjects": [ + { + "kind": "ServiceAccount", + "name": "blue-green-sa" + } + ] +} +] \ No newline at end of file diff --git a/blue-green-deploy/components/params.libsonnet b/blue-green-deploy/components/params.libsonnet index 4e14e47..2e74e3c 100644 --- a/blue-green-deploy/components/params.libsonnet +++ b/blue-green-deploy/components/params.libsonnet @@ -9,11 +9,11 @@ "bg-guestbook": { containerPort: 80, image: "gcr.io/heptio-images/ks-guestbook-demo:0.2", - name: "bg-guestbook", + name: "blue-green-guestbook", replicas: 3, servicePort: 80, type: "LoadBalancer", }, - "bg-workflow": {}, + "bg-pod": {}, }, } diff --git a/blue-green-deploy/environments/default/main.jsonnet b/blue-green-deploy/environments/default/main.jsonnet index 58695a8..1d4f642 100644 --- a/blue-green-deploy/environments/default/main.jsonnet +++ b/blue-green-deploy/environments/default/main.jsonnet @@ -1,8 +1,9 @@ local base = import "base.libsonnet"; // uncomment if you reference ksonnet-lib // local k = import "k.libsonnet"; +// local deployment = k.apps.v1beta2.deployment; base + { // Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n") - // "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"}) + // "nginx-deployment"+: deployment.mixin.metadata.withLabels({foo: "bar"}) } diff --git a/guestbook/guestbook-ui-deployment.yaml b/guestbook/guestbook-ui-deployment.yaml index 92fd91b..45182ce 100644 --- a/guestbook/guestbook-ui-deployment.yaml +++ b/guestbook/guestbook-ui-deployment.yaml @@ -1,4 +1,3 @@ ---- apiVersion: apps/v1beta2 kind: Deployment metadata: diff --git a/guestbook/guestbook-ui-svc.yaml b/guestbook/guestbook-ui-svc.yaml index d96a325..918bbc5 100644 --- a/guestbook/guestbook-ui-svc.yaml +++ b/guestbook/guestbook-ui-svc.yaml @@ -1,4 +1,3 @@ ---- apiVersion: v1 kind: Service metadata: diff --git a/jsonnet-guestbook/params.libsonnet b/jsonnet-guestbook/params.libsonnet index e51ab62..3120aad 100644 --- a/jsonnet-guestbook/params.libsonnet +++ b/jsonnet-guestbook/params.libsonnet @@ -1,7 +1,7 @@ { containerPort: 80, image: "gcr.io/heptio-images/ks-guestbook-demo:0.2", - name: "guestbook-ui", + name: "jsonnet-guestbook-ui", replicas: 1, servicePort: 80, type: "LoadBalancer", diff --git a/kustomize-guestbook/base/kustomization.yaml b/kustomize-guestbook/base/kustomization.yaml deleted file mode 100644 index 9f633bd..0000000 --- a/kustomize-guestbook/base/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ -namePrefix: kustomize- - -resources: -- ../../guestbook/guestbook-ui-deployment.yaml -- ../../guestbook/guestbook-ui-svc.yaml diff --git a/kustomize-guestbook/dev/kustomization.yaml b/kustomize-guestbook/dev/kustomization.yaml deleted file mode 100644 index c08e342..0000000 --- a/kustomize-guestbook/dev/kustomization.yaml +++ /dev/null @@ -1,7 +0,0 @@ -namePrefix: dev- - -bases: -- ../base - -commonLabels: - environment: dev diff --git a/kustomize-guestbook/kustomization.yaml b/kustomize-guestbook/kustomization.yaml new file mode 100644 index 0000000..526ff26 --- /dev/null +++ b/kustomize-guestbook/kustomization.yaml @@ -0,0 +1,5 @@ +namePrefix: kustomize- + +resources: +- ../guestbook/guestbook-ui-deployment.yaml +- ../guestbook/guestbook-ui-svc.yaml diff --git a/kustomize-guestbook/prod/kustomization.yaml b/kustomize-guestbook/prod/kustomization.yaml deleted file mode 100644 index ddde8be..0000000 --- a/kustomize-guestbook/prod/kustomization.yaml +++ /dev/null @@ -1,11 +0,0 @@ -namePrefix: prod- - -bases: -- ../base - -commonLabels: - environment: prod - -imageTags: - - name: gcr.io/heptio-images/ks-guestbook-demo - newTag: "0.1" diff --git a/pre-post-sync/kustomization.yaml b/pre-post-sync/kustomization.yaml new file mode 100644 index 0000000..35f8f92 --- /dev/null +++ b/pre-post-sync/kustomization.yaml @@ -0,0 +1,7 @@ +namePrefix: pre-post-sync- + +resources: +- ../guestbook/guestbook-ui-deployment.yaml +- ../guestbook/guestbook-ui-svc.yaml +- pre-sync-job.yaml +- post-sync-job.yaml diff --git a/pre-post-sync/components/post-sync-job.yaml b/pre-post-sync/post-sync-job.yaml similarity index 93% rename from pre-post-sync/components/post-sync-job.yaml rename to pre-post-sync/post-sync-job.yaml index af6bda1..cef38f0 100644 --- a/pre-post-sync/components/post-sync-job.yaml +++ b/pre-post-sync/post-sync-job.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: Job metadata: - generateName: after- + name: after annotations: argocd.argoproj.io/hook: PostSync argocd.argoproj.io/hook-delete-policy: HookSucceeded diff --git a/pre-post-sync/components/pre-sync-job.yaml b/pre-post-sync/pre-sync-job.yaml similarity index 93% rename from pre-post-sync/components/pre-sync-job.yaml rename to pre-post-sync/pre-sync-job.yaml index 3ee48c7..110ddeb 100644 --- a/pre-post-sync/components/pre-sync-job.yaml +++ b/pre-post-sync/pre-sync-job.yaml @@ -1,7 +1,7 @@ apiVersion: batch/v1 kind: Job metadata: - generateName: before- + name: before annotations: argocd.argoproj.io/hook: PreSync argocd.argoproj.io/hook-delete-policy: HookSucceeded diff --git a/sock-shop/.gitignore b/sock-shop/.gitignore deleted file mode 100644 index f8714d3..0000000 --- a/sock-shop/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/lib -/.ksonnet/registries -/app.override.yaml -/.ks_environment diff --git a/sock-shop/app.yaml b/sock-shop/app.yaml deleted file mode 100644 index ce69c97..0000000 --- a/sock-shop/app.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: 0.1.0 -environments: - default: - destination: - namespace: default - server: https://kubernetes.default.svc - k8sVersion: v1.10.0 - path: default -kind: ksonnet.io/app -name: sock-shop -version: 0.0.1 diff --git a/sock-shop/components/carts-db-dep.yaml b/sock-shop/base/carts-db-dep.yaml similarity index 100% rename from sock-shop/components/carts-db-dep.yaml rename to sock-shop/base/carts-db-dep.yaml diff --git a/sock-shop/components/carts-db-svc.yaml b/sock-shop/base/carts-db-svc.yaml similarity index 100% rename from sock-shop/components/carts-db-svc.yaml rename to sock-shop/base/carts-db-svc.yaml diff --git a/sock-shop/components/carts-dep.yaml b/sock-shop/base/carts-dep.yaml similarity index 100% rename from sock-shop/components/carts-dep.yaml rename to sock-shop/base/carts-dep.yaml diff --git a/sock-shop/components/catalogue-db-dep.yaml b/sock-shop/base/catalogue-db-dep.yaml similarity index 100% rename from sock-shop/components/catalogue-db-dep.yaml rename to sock-shop/base/catalogue-db-dep.yaml diff --git a/sock-shop/components/catalogue-db-svc.yaml b/sock-shop/base/catalogue-db-svc.yaml similarity index 100% rename from sock-shop/components/catalogue-db-svc.yaml rename to sock-shop/base/catalogue-db-svc.yaml diff --git a/sock-shop/components/catalogue-dep.yaml b/sock-shop/base/catalogue-dep.yaml similarity index 100% rename from sock-shop/components/catalogue-dep.yaml rename to sock-shop/base/catalogue-dep.yaml diff --git a/sock-shop/components/catalogue-svc.yaml b/sock-shop/base/catalogue-svc.yaml similarity index 100% rename from sock-shop/components/catalogue-svc.yaml rename to sock-shop/base/catalogue-svc.yaml diff --git a/sock-shop/components/front-end-dep.yaml b/sock-shop/base/front-end-dep.yaml similarity index 100% rename from sock-shop/components/front-end-dep.yaml rename to sock-shop/base/front-end-dep.yaml diff --git a/sock-shop/components/front-end-svc.yaml b/sock-shop/base/front-end-svc.yaml similarity index 100% rename from sock-shop/components/front-end-svc.yaml rename to sock-shop/base/front-end-svc.yaml diff --git a/sock-shop/components/orders-db-dep.yaml b/sock-shop/base/orders-db-dep.yaml similarity index 100% rename from sock-shop/components/orders-db-dep.yaml rename to sock-shop/base/orders-db-dep.yaml diff --git a/sock-shop/components/orders-db-svc.yaml b/sock-shop/base/orders-db-svc.yaml similarity index 100% rename from sock-shop/components/orders-db-svc.yaml rename to sock-shop/base/orders-db-svc.yaml diff --git a/sock-shop/components/orders-dep.yaml b/sock-shop/base/orders-dep.yaml similarity index 100% rename from sock-shop/components/orders-dep.yaml rename to sock-shop/base/orders-dep.yaml diff --git a/sock-shop/components/orders-svc.yaml b/sock-shop/base/orders-svc.yaml similarity index 100% rename from sock-shop/components/orders-svc.yaml rename to sock-shop/base/orders-svc.yaml diff --git a/sock-shop/components/payment-dep.yaml b/sock-shop/base/payment-dep.yaml similarity index 100% rename from sock-shop/components/payment-dep.yaml rename to sock-shop/base/payment-dep.yaml diff --git a/sock-shop/components/payment-svc.yaml b/sock-shop/base/payment-svc.yaml similarity index 100% rename from sock-shop/components/payment-svc.yaml rename to sock-shop/base/payment-svc.yaml diff --git a/sock-shop/components/queue-master-dep.yaml b/sock-shop/base/queue-master-dep.yaml similarity index 100% rename from sock-shop/components/queue-master-dep.yaml rename to sock-shop/base/queue-master-dep.yaml diff --git a/sock-shop/components/queue-master-svc.yaml b/sock-shop/base/queue-master-svc.yaml similarity index 100% rename from sock-shop/components/queue-master-svc.yaml rename to sock-shop/base/queue-master-svc.yaml diff --git a/sock-shop/components/rabbitmq-dep.yaml b/sock-shop/base/rabbitmq-dep.yaml similarity index 100% rename from sock-shop/components/rabbitmq-dep.yaml rename to sock-shop/base/rabbitmq-dep.yaml diff --git a/sock-shop/components/rabbitmq-svc.yaml b/sock-shop/base/rabbitmq-svc.yaml similarity index 100% rename from sock-shop/components/rabbitmq-svc.yaml rename to sock-shop/base/rabbitmq-svc.yaml diff --git a/sock-shop/components/session-db-dep.yaml b/sock-shop/base/session-db-dep.yaml similarity index 100% rename from sock-shop/components/session-db-dep.yaml rename to sock-shop/base/session-db-dep.yaml diff --git a/sock-shop/components/session-db-svc.yaml b/sock-shop/base/session-db-svc.yaml similarity index 100% rename from sock-shop/components/session-db-svc.yaml rename to sock-shop/base/session-db-svc.yaml diff --git a/sock-shop/components/shipping-dep.yaml b/sock-shop/base/shipping-dep.yaml similarity index 100% rename from sock-shop/components/shipping-dep.yaml rename to sock-shop/base/shipping-dep.yaml diff --git a/sock-shop/components/shipping-svc.yaml b/sock-shop/base/shipping-svc.yaml similarity index 100% rename from sock-shop/components/shipping-svc.yaml rename to sock-shop/base/shipping-svc.yaml diff --git a/sock-shop/components/user-db-dep.yaml b/sock-shop/base/user-db-dep.yaml similarity index 100% rename from sock-shop/components/user-db-dep.yaml rename to sock-shop/base/user-db-dep.yaml diff --git a/sock-shop/components/user-db-svc.yaml b/sock-shop/base/user-db-svc.yaml similarity index 100% rename from sock-shop/components/user-db-svc.yaml rename to sock-shop/base/user-db-svc.yaml diff --git a/sock-shop/components/user-dep.yaml b/sock-shop/base/user-dep.yaml similarity index 100% rename from sock-shop/components/user-dep.yaml rename to sock-shop/base/user-dep.yaml diff --git a/sock-shop/components/user-svc.yaml b/sock-shop/base/user-svc.yaml similarity index 100% rename from sock-shop/components/user-svc.yaml rename to sock-shop/base/user-svc.yaml diff --git a/sock-shop/components/params.libsonnet b/sock-shop/components/params.libsonnet deleted file mode 100644 index e3325e6..0000000 --- a/sock-shop/components/params.libsonnet +++ /dev/null @@ -1,37 +0,0 @@ -{ - global: { - // User-defined global parameters; accessible to all component and environments, Ex: - // replicas: 4, - }, - components: { - // Component-level parameters, defined initially from 'ks prototype use ...' - // Each object below should correspond to a component in the components/ directory - "carts-db-dep": {}, - "carts-db-svc": {}, - "carts-dep": {}, - "catalogue-db-dep": {}, - "catalogue-db-svc": {}, - "catalogue-dep": {}, - "catalogue-svc": {}, - "front-end-dep": {}, - "front-end-svc": {}, - "orders-db-dep": {}, - "orders-db-svc": {}, - "orders-dep": {}, - "orders-svc": {}, - "payment-dep": {}, - "payment-svc": {}, - "queue-master-dep": {}, - "queue-master-svc": {}, - "rabbitmq-dep": {}, - "rabbitmq-svc": {}, - "session-db-dep": {}, - "session-db-svc": {}, - "shipping-dep": {}, - "shipping-svc": {}, - "user-db-dep": {}, - "user-db-svc": {}, - "user-dep": {}, - "user-svc": {}, - }, -} diff --git a/sock-shop/environments/base.libsonnet b/sock-shop/environments/base.libsonnet deleted file mode 100644 index a129aff..0000000 --- a/sock-shop/environments/base.libsonnet +++ /dev/null @@ -1,4 +0,0 @@ -local components = std.extVar("__ksonnet/components"); -components + { - // Insert user-specified overrides here. -} diff --git a/sock-shop/environments/default/globals.libsonnet b/sock-shop/environments/default/globals.libsonnet deleted file mode 100644 index 7a73a41..0000000 --- a/sock-shop/environments/default/globals.libsonnet +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/sock-shop/environments/default/main.jsonnet b/sock-shop/environments/default/main.jsonnet deleted file mode 100644 index 58695a8..0000000 --- a/sock-shop/environments/default/main.jsonnet +++ /dev/null @@ -1,8 +0,0 @@ -local base = import "base.libsonnet"; -// uncomment if you reference ksonnet-lib -// local k = import "k.libsonnet"; - -base + { - // Insert user-specified overrides here. For example if a component is named \"nginx-deployment\", you might have something like:\n") - // "nginx-deployment"+: k.deployment.mixin.metadata.labels({foo: "bar"}) -} diff --git a/sock-shop/environments/default/params.libsonnet b/sock-shop/environments/default/params.libsonnet deleted file mode 100644 index b6eb32d..0000000 --- a/sock-shop/environments/default/params.libsonnet +++ /dev/null @@ -1,17 +0,0 @@ -local params = std.extVar("__ksonnet/params"); -local globals = import "globals.libsonnet"; -local envParams = params + { - components +: { - // Insert component parameter overrides here. Ex: - // guestbook +: { - // name: "guestbook-dev", - // replicas: params.global.replicas, - // }, - }, -}; - -{ - components: { - [x]: envParams.components[x] + globals, for x in std.objectFields(envParams.components) - }, -} diff --git a/sock-shop/kustomization.yaml b/sock-shop/kustomization.yaml new file mode 100644 index 0000000..bcc3578 --- /dev/null +++ b/sock-shop/kustomization.yaml @@ -0,0 +1,28 @@ +resources: +- base/carts-db-dep.yaml +- base/carts-db-svc.yaml +- base/carts-dep.yaml +- base/catalogue-db-dep.yaml +- base/catalogue-db-svc.yaml +- base/catalogue-dep.yaml +- base/catalogue-svc.yaml +- base/front-end-dep.yaml +- base/front-end-svc.yaml +- base/orders-db-dep.yaml +- base/orders-db-svc.yaml +- base/orders-dep.yaml +- base/orders-svc.yaml +- base/payment-dep.yaml +- base/payment-svc.yaml +- base/queue-master-dep.yaml +- base/queue-master-svc.yaml +- base/rabbitmq-dep.yaml +- base/rabbitmq-svc.yaml +- base/session-db-dep.yaml +- base/session-db-svc.yaml +- base/shipping-dep.yaml +- base/shipping-svc.yaml +- base/user-db-dep.yaml +- base/user-db-svc.yaml +- base/user-dep.yaml +- base/user-svc.yaml \ No newline at end of file