diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..697823ebf --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,14 @@ +FROM mcr.microsoft.com/devcontainers/go:1.22-bullseye + +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y + + # add cert authority for ssl +RUN mkdir -p /registry/certs && \ +openssl req -newkey rsa:4096 -nodes -sha256 -keyout /registry/certs/ociregistry.key -addext "subjectAltName = DNS:localhost" -x509 -days 365 -out /registry/certs/ociregistry.crt -subj "/C=DE/ST=Baden-Wuertemberg/L=Walldorf/O=SAP-LOCAL-DEV/OU=ocm/CN=localhost" +RUN cp /registry/certs/ociregistry.crt /usr/local/share/ca-certificates && \ + update-ca-certificates + + +RUN go install github.com/gardener/landscapercli/landscaper-cli@latest +RUN curl -s https://ocm.software/install.sh | sudo bash \ No newline at end of file diff --git a/.devcontainer/context.yaml b/.devcontainer/context.yaml new file mode 100644 index 000000000..cc266ee63 --- /dev/null +++ b/.devcontainer/context.yaml @@ -0,0 +1,11 @@ +apiVersion: landscaper.gardener.cloud/v1alpha1 +kind: Context +metadata: + name: default-context + namespace: default + +repositoryContext: + baseUrl: localhost:443 + type: ociRegistry + +useOCM: true \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..1b7b27129 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,96 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile +{ + "name": "Existing Dockerfile", + "build": { + // Sets the run context to one level up instead of the .devcontainer folder. + "context": "..", + // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename. + "dockerfile": "Dockerfile" + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "moby": true, + "azureDnsAutoDetection": true, + "installDockerBuildx": true, + "version": "latest", + "dockerDashComposeVersion": "v2" + }, + "ghcr.io/devcontainers/features/kubectl-helm-minikube:1": { + "version": "latest", + "helm": "latest", + "minikube": "latest" + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment the next line to run commands after the container is created. + "postCreateCommand": "bash .devcontainer/scripts/post-create.sh", + "postStartCommand": "bash .devcontainer/scripts/post-start.sh", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "settings": { + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "DCON: Landscaper Minikube debug", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/cmd/landscaper-controller/main.go", + "args": [ + "--config=${workspaceFolder}/.devcontainer/landscaper-config.yaml", + "--deployers=container,helm,mock,manifest", + ], + "env": { + "KUBECONFIG": "/home/vscode/.kube/kubeconfig--minikube-local.yaml" + }, + }, + { + "name": "DCON: HelmDeployer Minikube debug", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/cmd/helm-deployer-controller/main.go", + "args": [ + "--config=${workspaceFolder}/.devcontainer/landscaper-config.yaml", + ], + "env": { + "KUBECONFIG": "/home/vscode/.kube/kubeconfig--minikube-local.yaml" + }, + }, + { + "name": "DCON: ManifestDeployer Minikube debug", + "type": "go", + "request": "launch", + "mode": "debug", + "program": "${workspaceFolder}/cmd/manifest-deployer-controller/main.go", + "args": [ + "--config=${workspaceFolder}/.devcontainer/landscaper-config.yaml", + ], + "env": { + "KUBECONFIG": "/home/vscode/.kube/kubeconfig--minikube-local.yaml" + }, + }, + ], + "compounds": [] + } + }, + "extensions": [ + "ms-kubernetes-tools.vscode-kubernetes-tools", + "ms-azuretools.vscode-docker", + "golang.go" + ] + } + }, + + // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "devcontainer" +} diff --git a/.devcontainer/landscaper-config.yaml b/.devcontainer/landscaper-config.yaml new file mode 100644 index 000000000..d701760f5 --- /dev/null +++ b/.devcontainer/landscaper-config.yaml @@ -0,0 +1,22 @@ +deployers: +- container +- helm +- manifest +- mock + +deployerManagement: + disable: false + agent: + disable: false + +useOCMLib: true + +# deployItemTimeouts: +# pickup: 10s +# abort: 10s +# progressingDefault: 1m + +crdManagement: + deployCrd: true + forceUpdate: true + diff --git a/.devcontainer/sample-installation/blueprint/blueprint.yaml b/.devcontainer/sample-installation/blueprint/blueprint.yaml new file mode 100644 index 000000000..d84c24fd6 --- /dev/null +++ b/.devcontainer/sample-installation/blueprint/blueprint.yaml @@ -0,0 +1,32 @@ +apiVersion: landscaper.gardener.cloud/v1alpha1 +kind: Blueprint +jsonSchema: "https://json-schema.org/draft/2019-09/schema" + +imports: + - name: cluster + type: target + targetType: landscaper.gardener.cloud/kubernetes-cluster + +deployExecutions: + - name: default + type: GoTemplate + template: | + deployItems: + - name: default-deploy-item + type: landscaper.gardener.cloud/helm + + target: + import: cluster + + config: + apiVersion: helm.deployer.landscaper.gardener.cloud/v1alpha1 + kind: ProviderConfiguration + name: hello-world + namespace: example + createNamespace: true + + chart: + ref: eu.gcr.io/gardener-project/landscaper/examples/charts/hello-world:1.0.0 + + values: + testData: hello \ No newline at end of file diff --git a/.devcontainer/sample-installation/components.yaml b/.devcontainer/sample-installation/components.yaml new file mode 100644 index 000000000..4c10c821e --- /dev/null +++ b/.devcontainer/sample-installation/components.yaml @@ -0,0 +1,15 @@ +components: + - name: registry.local/sample/component + version: v1.0.0 + provider: + name: internal + resources: + - name: blueprint + type: landscaper.gardener.cloud/blueprint + # the available input types can be found in the help of the command line tool through + # ocm add resources --help + input: + type: dir + path: ./blueprint + compress: true + mediaType: application/vnd.gardener.landscaper.blueprint.v1+tar+gzip \ No newline at end of file diff --git a/.devcontainer/sample-installation/installation.yaml b/.devcontainer/sample-installation/installation.yaml new file mode 100644 index 000000000..afd64b5cc --- /dev/null +++ b/.devcontainer/sample-installation/installation.yaml @@ -0,0 +1,25 @@ +apiVersion: landscaper.gardener.cloud/v1alpha1 +kind: Installation +metadata: + name: sample + namespace: default + annotations: + landscaper.gardener.cloud/operation: reconcile + +spec: + context: default-context + + componentDescriptor: + ref: + componentName: registry.local/sample/component + version: v1.0.0 + + blueprint: + ref: + resourceName: blueprint + + # Set values for the import parameters of the blueprint + imports: + targets: + - name: cluster # name of an import parameter of the blueprint + target: minikube-from-host # name of the Target custom resource containing the kubeconfig of the target cluster \ No newline at end of file diff --git a/.devcontainer/scripts/post-create.sh b/.devcontainer/scripts/post-create.sh new file mode 100644 index 000000000..446755971 --- /dev/null +++ b/.devcontainer/scripts/post-create.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +# run once on post-create and it will be always restarted automatically when the container restarts +echo "Start or create registry" +docker start registry || docker run -d -p 443:443 --restart always --name registry \ +-v /registry/certs/:/certs \ +-e REGISTRY_HTTP_ADDR=:443 \ +-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/ociregistry.crt \ +-e REGISTRY_HTTP_TLS_KEY=/certs/ociregistry.key \ +registry:2 + +echo "Start minikube" +minikube start + +# apply CRDs to minikube +echo "Apply landscaper CRDs to minikube cluster" +kubectl apply -f /workspaces/landscaper/.crd/ + +# create sample ocm componentversion and add it to registry +echo "Create and push a sample componentversion with blueprint" +ocm add components --create --file /workspaces/landscaper/.devcontainer/sample-installation/sample-component /workspaces/landscaper/.devcontainer/sample-installation/components.yaml +ocm transfer ctf /workspaces/landscaper/.devcontainer/sample-installation/sample-component OCIRegistry::localhost:443 \ No newline at end of file diff --git a/.devcontainer/scripts/post-start.sh b/.devcontainer/scripts/post-start.sh new file mode 100644 index 000000000..c7f8dd254 --- /dev/null +++ b/.devcontainer/scripts/post-start.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +# TODO check if this is necessary or if it will be automatically started +if [ $( docker ps -a -f name=minikube | wc -l ) -eq 2 ]; then + echo "minikube already started" +else + echo "minikube not started yet, creating..." + minikube start +fi + +echo "Exporting minikube config to yaml file" +kubectl config view --raw > ~/.kube/kubeconfig--minikube-local.yaml + +echo "Build minikube target and apply to cluster" +# creates a target.landscaper.gardener.cloud by combining the target.yaml with an indended minikube kubeconfig. Uses <() as process substitution to use command output as a file for kubectl +kubectl apply -f <(cat .devcontainer/target-template.yaml; cat ~/.kube/kubeconfig--minikube-local.yaml | sed 's/^/ /') + +echo "Apply context to cluster" +kubectl apply -f /workspaces/landscaper/.devcontainer/context.yaml \ No newline at end of file diff --git a/.devcontainer/target-template.yaml b/.devcontainer/target-template.yaml new file mode 100644 index 000000000..04b5121bf --- /dev/null +++ b/.devcontainer/target-template.yaml @@ -0,0 +1,9 @@ +apiVersion: landscaper.gardener.cloud/v1alpha1 +kind: Target +metadata: + name: minikube-from-host + namespace: default +spec: + type: landscaper.gardener.cloud/kubernetes-cluster + config: + kubeconfig: | diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..f33a02cd1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for more information: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://containers.dev/guide/dependabot + +version: 2 +updates: + - package-ecosystem: "devcontainers" + directory: "/" + schedule: + interval: weekly