Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ crossplane configurations, apis and examples

## DEV KIND CLUSTER DEPLOYMENT & CONFIGURATION OF CROSSPLANE

<details><summary><b>CREATE KIND CLUSTER w/ DAGGER (DOCKER MUST RUN ON THE MACHINE)</b></summary>
<details><summary><b>CREATE KIND CLUSTER w/ DAGGER (DOCKER+KIND ARE REQUIRED)</b></summary>

```bash
export TASK_X_REMOTE_TASKFILES=1
Expand Down Expand Up @@ -32,7 +32,6 @@ execute-ansible \

</details>


<details><summary><b>CROSSPLANE DEPLOYMENT w/ DAGGER/HELMFILE</b></summary>

```bash
Expand Down Expand Up @@ -62,7 +61,6 @@ kubectl apply -k https://github.com/stuttgart-things/helm/cicd/crds/tekton
```

```bash
# DEPLOY OPENEBS w/ DAGGER
dagger call -m github.com/stuttgart-things/dagger/helm@v0.57.0 \
helmfile-operation \
--helmfile-ref "git::https://github.com/stuttgart-things/helm.git@infra/openebs.yaml.gotmpl" \
Expand Down
4 changes: 1 addition & 3 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ includes:
taskfile: https://raw.githubusercontent.com/stuttgart-things/tasks/refs/heads/main/configuration/k2n.yaml

tasks:


push-configuration-package:
desc: Push crossplane configuration package
cmds:
Expand Down Expand Up @@ -86,7 +84,7 @@ tasks:
SOURCE_FOLDER: "./configurations"
ALL_CONFIGURATION_PACKAGES:
sh: |
find {{ .SOURCE_FOLDER }}/k8s {{ .SOURCE_FOLDER }}/cluster {{ .SOURCE_FOLDER }}/infra {{ .SOURCE_FOLDER }}/config {{ .SOURCE_FOLDER }}/terraform {{ .SOURCE_FOLDER }}/apps \
find {{ .SOURCE_FOLDER }}/claims {{ .SOURCE_FOLDER }}/k8s {{ .SOURCE_FOLDER }}/infra {{ .SOURCE_FOLDER }}/config {{ .SOURCE_FOLDER }}/terraform {{ .SOURCE_FOLDER }}/apps \
-mindepth 1 -maxdepth 1 -type d | \
sed "s|^\./configurations/||" | \
sort | \
Expand Down
22 changes: 22 additions & 0 deletions cmds.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# COMMANDS/TROUBLESHOOTING

<details><summary><b>HELM RELEASES</b></summary>

```bash
kubectl get releases.helm.m.crossplane.io -A
kubectl get releases.helm.crossplane.io -A
```

</details>

<details><summary><b>DEBUG CROSSPLANE PROVIDER</b></summary>

```bash
Expand Down Expand Up @@ -39,3 +48,16 @@ EOF
```

</details>

<details><summary><b>CREATE KCL SCHEMAS FROM XRD</b></summary>

```bash
# APPLY AGAINST K8S
kubectl apply -f ./definition.yaml
# READ CRD
kubectl get crd volumeclaims.resources.stuttgart-things.com -o yaml > /tmp/generated-crd-vc.yaml
# CREATE SCHEMA w/ KCL
kcl import -m crd /tmp/generated-crd-vc.yaml -o /tmp/schema
```

</details>
2 changes: 1 addition & 1 deletion configurations/infra/storage-platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```bash
# RENDER NFS
crossplane render examples/nfs.yaml \
./compositions/storageplatform-openebs.yaml \
./compositions/storageplatform-nfs.yaml \
examples/functions.yaml \
--include-function-results
```
Expand Down
31 changes: 15 additions & 16 deletions configurations/infra/storage-platform/apis/definition.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---
apiVersion: apiextensions.crossplane.io/v2
kind: CompositeResourceDefinition
metadata:
name: storageplatforms.storage.platform.example.org
name: storageplatforms.resources.stuttgart-things.com
spec:
group: storage.platform.example.org
group: resources.stuttgart-things.com
defaultCompositeDeletePolicy: Foreground
scope: Namespaced

names:
kind: StoragePlatform
plural: storageplatforms
singular: storageplatform

versions:
- name: v1alpha1
served: true
Expand All @@ -26,7 +25,6 @@ spec:
required:
- engine
properties:

engine:
type: object
required:
Expand All @@ -38,22 +36,23 @@ spec:
- openebs
- nfs
description: Selected storage engine

providerConfigRef:
targetCluster:
type: object
description: Helm provider override
required:
- name
properties:
name:
type: string
default: helm-provider-cluster

kubernetesProviderConfigRef:
type: object
description: Kubernetes provider override
properties:
name:
description: Name of the ProviderConfig / ClusterProviderConfig
scope:
type: string
default: kubernetes-provider-cluster
enum:
- Namespaced
- Cluster
default: Namespaced
description: |
Whether to use ProviderConfig (Namespaced)
or ClusterProviderConfig (Cluster)

# --------------------
# OpenEBS configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ kind: Composition
metadata:
name: storageplatform-nfs
labels:
crossplane.io/xrd: storageplatforms.storage.platform.example.org
crossplane.io/xrd: storageplatforms.resources.stuttgart-things.com
storage.platform.example.org/engine: nfs
spec:
compositeTypeRef:
apiVersion: storage.platform.example.org/v1alpha1
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: StoragePlatform
mode: Pipeline
pipeline:
Expand All @@ -24,6 +24,13 @@ spec:
{{- $spec := .observed.composite.resource.spec -}}
{{- $nfs := $spec.nfs -}}

{{- $scope := $spec.targetCluster.scope | default "Namespaced" -}}
{{- $pcKind := "ProviderConfig" -}}
{{- if eq $scope "Cluster" -}}
{{- $pcKind = "ClusterProviderConfig" -}}
{{- end -}}

{{- if $nfs.namespace }}
---
apiVersion: helm.m.crossplane.io/v1beta1
kind: Release
Expand All @@ -36,38 +43,29 @@ spec:
storage.platform.example.org/engine: nfs
spec:
deletionPolicy: Delete

providerConfigRef:
name: {{ $spec.providerConfigRef.name | default "helm-provider-cluster" }}
kind: ClusterProviderConfig

name: {{ $spec.targetCluster.name }}
kind: {{ $pcKind }}
forProvider:
namespace: {{ $nfs.namespace | default "kube-system" }}

chart:
name: csi-driver-nfs
repository: https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
version: {{ $nfs.version | default "v4.11.0" }}

values:
serviceAccount:
create: {{ $nfs.serviceAccountCreate | default true }}
controller: {{ $nfs.serviceAccountController | default "csi-nfs-controller-sa" }}

rbac:
create: {{ $nfs.rbacCreate | default true }}
name: {{ $nfs.rbacName | default "nfs" }}

driver:
name: {{ $nfs.driverName | default "nfs.csi.k8s.io" }}
mountPermissions: {{ $nfs.mountPermissions | default 0 }}

feature:
enableFSGroupPolicy: {{ $nfs.enableFSGroupPolicy | default true }}
enableInlineVolume: {{ $nfs.enableInlineVolume | default false }}

kubeletDir: {{ $nfs.kubeletDir | default "/var/lib/kubelet" }}

externalSnapshotter:
enabled: {{ $nfs.externalSnapshotterEnabled | default false }}

Expand All @@ -83,11 +81,9 @@ spec:
storage.platform.example.org/engine: nfs
spec:
deletionPolicy: Delete

providerConfigRef:
name: {{ $spec.kubernetesProviderConfigRef.name | default "kubernetes-provider-cluster" }}
kind: ClusterProviderConfig

name: {{ $spec.targetCluster.name }}
kind: {{ $pcKind }}
forProvider:
manifest:
apiVersion: storage.k8s.io/v1
Expand All @@ -106,10 +102,8 @@ spec:
{{- range $nfs.mountOptions | default (list "nfsvers=4.1") }}
- {{ . }}
{{- end }}
{{- end }}

---
apiVersion: storage.platform.example.org/v1alpha1
kind: StoragePlatform
status:
installed: true
observedVersion: {{ $nfs.version | default "v4.11.0" }}
- step: automatically-detect-ready-composed-resources
functionRef:
name: function-auto-ready
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ kind: Composition
metadata:
name: storageplatform-openebs
labels:
crossplane.io/xrd: storageplatforms.storage.platform.example.org
crossplane.io/xrd: storageplatforms.resources.stuttgart-things.com
storage.platform.example.org/engine: openebs
spec:
compositeTypeRef:
apiVersion: storage.platform.example.org/v1alpha1
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: StoragePlatform
mode: Pipeline
pipeline:
Expand All @@ -20,51 +20,81 @@ spec:
kind: GoTemplate
source: Inline
inline:
template: | # pragma: allowlist secret
template: |
{{- $spec := .observed.composite.resource.spec -}}
{{- $openebs := $spec.openebs -}}

{{- $scope := $spec.targetCluster.scope | default "Namespaced" -}}
{{- $pcKind := "ProviderConfig" -}}
{{- if eq $scope "Cluster" -}}
{{- $pcKind = "ClusterProviderConfig" -}}
{{- end -}}

{{- if $openebs.namespace }}
---
apiVersion: kubernetes.m.crossplane.io/v1alpha1
kind: Object
metadata:
annotations:
{{ setResourceNameAnnotation "openebs-namespace" }}
spec:
providerConfigRef:
name: {{ $spec.targetCluster.name }}
kind: {{ $pcKind }}
forProvider:
manifest:
apiVersion: v1
kind: Namespace
metadata:
name: {{ $openebs.namespace }}
{{- end }}

---
apiVersion: helm.m.crossplane.io/v1beta1
kind: Release
metadata:
annotations:
{{ setResourceNameAnnotation "openebs-release" }}
labels:
app.kubernetes.io/name: openebs
app.kubernetes.io/managed-by: crossplane
storage.platform.example.org/engine: openebs
spec:
providerConfigRef:
name: {{ $spec.providerConfigRef.name | default "helm-provider-cluster" }}
kind: ProviderConfig

name: {{ $spec.targetCluster.name }}
kind: {{ $pcKind }}
forProvider:
namespace: {{ $spec.openebs.namespace | default "openebs-system" }}

namespace: {{ $openebs.namespace | default "openebs-system" }}
chart:
name: openebs
repository: https://openebs.github.io/openebs
version: {{ $spec.openebs.version | default "4.2.0" }}

repository: {{ $openebs.chartRepository | default "https://openebs.github.io/openebs" }}
version: {{ $openebs.version | default "4.2.0" }}
values:
openebs-crds:
csi:
volumeSnapshots:
enabled: {{ $spec.openebs.features.volumeSnapshots | default false }}
enabled: {{ $openebs.features.volumeSnapshots | default false }}

mayastor:
csi:
node:
initContainers:
enabled: {{ $spec.openebs.features.csiNodeInitContainers | default false }}
enabled: {{ $openebs.features.csiNodeInitContainers | default false }}

engines:
local:
lvm:
enabled: {{ $spec.openebs.engines.local.lvm | default false }}
enabled: {{ $openebs.engines.local.lvm | default false }}
zfs:
enabled: {{ $spec.openebs.engines.local.zfs | default false }}
enabled: {{ $openebs.engines.local.zfs | default false }}

replicated:
mayastor:
enabled: {{ $spec.openebs.engines.replicated.mayastor | default false }}
enabled: {{ $openebs.engines.replicated.mayastor | default false }}

---
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: StoragePlatform
status:
installed: true
observedVersion: {{ $openebs.version | default "4.2.0" }}

- step: automatically-detect-ready-composed-resources
functionRef:
name: function-auto-ready
7 changes: 7 additions & 0 deletions configurations/infra/storage-platform/examples/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ metadata:
name: function-go-templating
spec:
package: xpkg.crossplane.io/crossplane-contrib/function-go-templating:v0.11.3
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-auto-ready
spec:
package: xpkg.crossplane.io/crossplane-contrib/function-auto-ready:v0.6.0
10 changes: 5 additions & 5 deletions configurations/infra/storage-platform/examples/nfs.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
apiVersion: storage.platform.example.org/v1alpha1
apiVersion: resources.stuttgart-things.com/v1alpha1
kind: StoragePlatform
metadata:
name: nfs-storage
spec:
engine:
type: nfs
providerConfigRef:
name: helm-provider-prod
kubernetesProviderConfigRef:
name: kubernetes-provider-prod
targetCluster:
name: in-cluster
scope: Cluster
nfs:
namespace: kube-system
serverFQDN: nfs.example.com
sharePath: /exports/k8s
storageClass: nfs-client
Expand Down
Loading