diff --git a/.dockerignore b/.dockerignore index a387873..6b3398b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ node_modules example +.devspace diff --git a/.gitignore b/.gitignore index 0e40b97..b481374 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ node_modules/ dist/ example/ package-lock.json + + +# Ignore DevSpace cache and log folder +.devspace/ diff --git a/devspace.yaml b/devspace.yaml new file mode 100755 index 0000000..2306375 --- /dev/null +++ b/devspace.yaml @@ -0,0 +1,101 @@ +version: v1beta11 + +# `vars` specifies variables which may be used as ${VAR_NAME} in devspace.yaml +vars: +- name: IMAGE + value: bored + +# `deployments` tells DevSpace how to deploy this project +images: + catalog-api-autoscaler: + image: trow.${DEVSPACE_NAMESPACE}.svc.cluster.local:8000/${IMAGE} + tags: + - latest + build: + kaniko: + insecure: true +deployments: +- name: helpers + kubectl: + manifests: + - devspace/ +- name: lens-space-proxy + # This deployment uses `helm` but you can also define `kubectl` deployments or kustomizations + helm: + # We are deploying the so-called Component Chart: https://devspace.sh/component-chart/docs + componentChart: true + # Under `values` we can define the values for this Helm chart used during `helm install/upgrade` + # You may also use `valuesFiles` to load values from files, e.g. valuesFiles: ["values.yaml"] + values: + containers: + - image: localhost:30999/${IMAGE} # Use the value of our `${IMAGE}` variable here (see vars above) + env: + - name: IDP_PUBLIC_KEY + value: | + -----BEGIN PUBLIC KEY----- + MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnzyis1ZjfNB0bBgKFMSv + vkTtwlvBsaJq7S5wA+kzeVOVpVWwkWdVha4s38XM/pa/yr47av7+z3VTmvDRyAHc + aT92whREFpLv9cj5lTeJSibyr/Mrm/YtjCZVWgaOYIhwrXwKLqPr/11inWsAkfIy + tvHWTxZYEcXLgAXFuUuaS3uF9gEiNQwzGTU1v0FqkqTBr4B8nW3HCN47XUu0t8Y0 + e+lf4s4OxQawWD79J9/5d3Ry0vbV3Am1FtGJiJvOwRsIfVChDpYStTcHTCMqtvWb + V6L11BWkpzGXSW4Hv43qa+GSYOD2QU68Mb59oSk2OB+BtOLpJofmbGEGgvmwyCI9 + MwIDAQAB + -----END PUBLIC KEY----- + +# `dev` only applies when you run `devspace dev` +dev: + # `dev.sync` configures a file sync between our Pods in k8s and your local project files + sync: + - imageSelector: ${IMAGE} # Select the Pod that runs our `${IMAGE}` + excludePaths: + - .git/ + uploadExcludePaths: + - node_modules + - example + - .devspace + + # `dev.terminal` tells DevSpace to open a terminal as a last step during `devspace dev` + terminal: + imageSelector: ${IMAGE} # Select the Pod that runs our `${IMAGE}` + # With this optional `command` we can tell DevSpace to run a script when opening the terminal + # This is often useful to display help info for new users or perform initial tasks (e.g. installing dependencies) + # DevSpace has generated an example ./devspace_start.sh file in your local project - Feel free to customize it! + command: + - ./devspace_start.sh + + # Since our Helm charts and manifests deployments are often optimized for production, + # DevSpace let's you swap out Pods dynamically to get a better dev environment + replacePods: + - imageSelector: ${IMAGE} # Select the Pod that runs our `${IMAGE}` + # Since the `${IMAGE}` used to start our main application pod may be distroless or not have any dev tooling, let's replace it with a dev-optimized image + # DevSpace provides a sample image here but you can use any image for your specific needs + replaceImage: loftsh/alpine:latest + # Besides replacing the container image, let's also apply some patches to the `spec` of our Pod + # We are overwriting `command` + `args` for the first container in our selected Pod, so it starts with `sleep 9999999` + # Using `sleep 9999999` as PID 1 (instead of the regular ENTRYPOINT), allows you to start the application manually + patches: + - op: replace + path: spec.containers[0].command + value: + - sleep + - op: replace + path: spec.containers[0].args + value: + - "9999999" + - op: remove + path: spec.containers[0].securityContext +hooks: +- name: registry + command: "helm get notes trow > /dev/null || helm upgrade trow trow --namespace ${DEVSPACE_NAMESPACE} --install --repo https://trow.io" + events: ["before:build"] +# `profiles` lets you modify the config above for different environments (e.g. dev vs production) +profiles: + # This profile is called `production` and you can use it for example using: devspace deploy -p production + # We generally recommend to use the base config without any profiles as optimized for development (e.g. image build+push is disabled) +- name: production +# This profile adds our image to the config so that DevSpace will build, tag and push our image before the deployment + merge: + images: + app: + image: ${IMAGE} # Use the value of our `${IMAGE}` variable here (see vars above) + dockerfile: ./Dockerfile diff --git a/devspace/trow-service.yaml b/devspace/trow-service.yaml new file mode 100644 index 0000000..e9d0890 --- /dev/null +++ b/devspace/trow-service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: trow-30999 +spec: + ports: + - protocol: TCP + port: 8000 + targetPort: http + nodePort: 30999 + selector: + app.kubernetes.io/instance: trow + app.kubernetes.io/name: trow + type: NodePort diff --git a/devspace_start.sh b/devspace_start.sh new file mode 100755 index 0000000..324c1d7 --- /dev/null +++ b/devspace_start.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +COLOR_CYAN="\033[0;36m" +COLOR_RESET="\033[0m" + +echo -e "${COLOR_CYAN} + ____ ____ + | _ \ _____ __/ ___| _ __ __ _ ___ ___ + | | | |/ _ \ \ / /\___ \| '_ \ / _\` |/ __/ _ \\ + | |_| | __/\ V / ___) | |_) | (_| | (_| __/ + |____/ \___| \_/ |____/| .__/ \__,_|\___\___| + |_| +${COLOR_RESET} + +Welcome to your development container! +This is how you can work with it: +- ${COLOR_CYAN}Files will be synchronized${COLOR_RESET} between your local machine and this container +- Certain files may be excluded from sync (see devspace.yaml) +" + +bash