Skip to content

Commit

Permalink
Prepare workshop
Browse files Browse the repository at this point in the history
commit 8f311c1daa1c2cc652186348ca4bf3bb93ff55e3
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Sat Oct 19 21:08:26 2024 +0100

    Move dir

commit af537004201e7c01ea7f2aa8cf0f18825d56d840
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Sat Oct 19 20:54:11 2024 +0100

    Add some more comments

commit cb26c4264c2cd51ae4fcb8fb38ac09521dc213c9
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 16:59:47 2024 +0100

    Commit

commit 5da0a25f6696a57089b1f055bac193862ac450e5
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 16:21:44 2024 +0100

    Testing

commit e8c5c0375751d008fa594ecaed42be68059fb32a
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 14:35:06 2024 +0100

    Working on mega

commit 0bcfcce163e97da62f6ad4ca0da12465016b85b9
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 14:17:30 2024 +0100

    Progress

commit a981d46c521fda13b43523bb888ccb0524848ff4
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 13:38:56 2024 +0100

    Composing

commit 02323e22a0de4eefb0c455ae65e1f6fe81e8f431
Author: Andrei Pohilko <andrei.pokhilko@gmail.com>
Date:   Fri Oct 18 13:14:05 2024 +0100

    Workshop draft
  • Loading branch information
undera committed Oct 21, 2024
1 parent 1553a12 commit e3a75d8
Show file tree
Hide file tree
Showing 15 changed files with 537 additions and 4 deletions.
4 changes: 0 additions & 4 deletions examples/helm-stage1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ metadata:
name: provider-helm-cc
spec:
serviceAccountName: provider-helm-sa




---
apiVersion: pkg.crossplane.io/v1
kind: Provider
Expand Down
35 changes: 35 additions & 0 deletions examples/workshop/00-pre-setup-sa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: providers-sa
namespace: crossplane-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: providers-cr
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch", "create", "delete", "patch", "update"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: providers-cr
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: providers-cr
subjects:
- kind: ServiceAccount
name: providers-sa
namespace: crossplane-system
---
apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
name: providers-cc
spec:
serviceAccountName: providers-sa
9 changes: 9 additions & 0 deletions examples/workshop/01-k8s-step1-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-kubernetes
spec:
package: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.15.0
controllerConfigRef:
name: providers-cc # gives it in-cluster write access to create namespaces and other resources
8 changes: 8 additions & 0 deletions examples/workshop/02-k8s-step2-providerconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: kubernetes.crossplane.io/v1alpha1
kind: ProviderConfig
metadata:
name: k8s-provider-pc
spec:
credentials:
source: InjectedIdentity
54 changes: 54 additions & 0 deletions examples/workshop/03-k8s-step3-mr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
name: ns-for-jobs
spec:
providerConfigRef:
name: k8s-provider-pc
forProvider:
manifest:
apiVersion: v1
kind: Namespace
metadata:
name: workshop-provider-k8s

---
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
metadata:
name: stray-pod
spec:
providerConfigRef:
name: k8s-provider-pc
forProvider:
manifest:
apiVersion: v1
kind: Pod
metadata:
namespace: workshop-provider-k8s
name: pod-orphan-or-stray
spec:
restartPolicy: Always
containers:
- name: demo-dates
image: busybox:latest
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- ping -w 60 -i 5 localhost && exit $((RANDOM % 2))


# Generic template for K8s Managed Resource:
# ---
# apiVersion: kubernetes.crossplane.io/v1alpha2
# kind: Object
# metadata:
# name: <MR name>
# spec:
# providerConfigRef:
# name: k8s-provider-pc
# forProvider:
# manifest:
# <any k8s resource manifest goes here>
9 changes: 9 additions & 0 deletions examples/workshop/04-helm-step1-provider.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-helm
spec:
package: xpkg.upbound.io/crossplane-contrib/provider-helm:v0.19.0
controllerConfigRef:
name: providers-cc # gives it in-cluster write access to create namespaces and other resources
8 changes: 8 additions & 0 deletions examples/workshop/05-helm-step2-providerconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: helm.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: helm-provider-pc
spec:
credentials:
source: InjectedIdentity
20 changes: 20 additions & 0 deletions examples/workshop/06-helm-step3-mr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
name: apache-example-mr
spec:
providerConfigRef:
name: helm-provider-pc
forProvider:
chart:
repository: https://charts.bitnami.com/bitnami
name: apache
version: 11.2.21
namespace: workshop-provider-helm
set:
- name: param1
value: value1
values:
service:
type: ClusterIP
31 changes: 31 additions & 0 deletions examples/workshop/07-composite-step1-define-xrd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xkomodorchartsets.xrd.komodor.com
spec:
group: xrd.komodor.com
names:
kind: XKomodorChartSet
plural: xkomodorchartsets
claimNames:
kind: KomodorChartSet
plural: komodorchartsets
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
hdashboardVer:
type: string
komoplaneVer:
type: string
required:
- hdashboardVer
- komoplaneVer
45 changes: 45 additions & 0 deletions examples/workshop/08-composite-step2-define-composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example-komodorset-composition
spec:
compositeTypeRef:
apiVersion: xrd.komodor.com/v1alpha1
kind: XKomodorChartSet
resources:
- name: khd-instance
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
providerConfigRef:
name: helm-provider-pc
forProvider:
chart:
repository: https://helm-charts.komodor.io
name: helm-dashboard
version: 0.1.10
namespace: komodor
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.hdashboardVer
toFieldPath: spec.forProvider.chart.version

- name: komoplane-instance
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
providerConfigRef:
name: helm-provider-pc
forProvider:
chart:
repository: https://helm-charts.komodor.io
name: komoplane
version: 0.1.5
namespace: komodor
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.komoplaneVer
toFieldPath: spec.forProvider.chart.version
8 changes: 8 additions & 0 deletions examples/workshop/09-composite-step3-use-direct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: xrd.komodor.com/v1alpha1
kind: XKomodorChartSet # Direct XR-style
metadata:
name: my-test-set1
spec:
hdashboardVer: 0.1.8
komoplaneVer: 0.1.4
19 changes: 19 additions & 0 deletions examples/workshop/10-composite-step4-use-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: xrd.komodor.com/v1alpha1
kind: KomodorChartSet # Claim-style
metadata:
namespace: default
name: my-test-set2
spec:
hdashboardVer: 0.1.10
komoplaneVer: 0.1.5

---
apiVersion: xrd.komodor.com/v1alpha1
kind: KomodorChartSet # Claim-style
metadata:
namespace: workshop-provider-helm
name: my-test-set3
spec:
hdashboardVer: 0.1.9
komoplaneVer: 0.1.3 # would not exist, causing troubleshooting
87 changes: 87 additions & 0 deletions examples/workshop/11-mega-step1-define.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xmegas.xrd.komodor.com
spec:
group: xrd.komodor.com
names:
kind: XMega
plural: xmegas
claimNames:
kind: Mega
plural: megas
versions:
- name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
namespace:
type: string
required:
- namespace
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: mega-composition
spec:
compositeTypeRef:
apiVersion: xrd.komodor.com/v1alpha1
kind: XMega
resources:
- name: provider-k8s-resource
base:
apiVersion: kubernetes.crossplane.io/v1alpha2
kind: Object
spec:
providerConfigRef:
name: k8s-provider-pc
forProvider:
manifest:
apiVersion: v1
kind: Namespace
metadata:
name: "" # will be set via patches
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.namespace
toFieldPath: spec.forProvider.manifest.metadata.name

- name: provider-helm-release
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
spec:
providerConfigRef:
name: helm-provider-pc
forProvider:
chart:
repository: https://charts.bitnami.com/bitnami
name: apache
version: 11.2.21
namespace: "default" # This will be dynamically overwritten
skipCreateNamespace: true
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.namespace
toFieldPath: spec.forProvider.namespace
- name: composition-of-compositions
base:
apiVersion: xrd.komodor.com/v1alpha1
kind: XKomodorChartSet
metadata:
namespace: ""
spec:
hdashboardVer: 0.1.10
komoplaneVer: 0.1.5
patches:
- type: FromCompositeFieldPath
fromFieldPath: spec.namespace
toFieldPath: metadata.namespace
8 changes: 8 additions & 0 deletions examples/workshop/12-mega-step2-claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
apiVersion: xrd.komodor.com/v1alpha1
kind: Mega
metadata:
namespace: default
name: mega-composition-instance1
spec:
namespace: test1
Loading

0 comments on commit e3a75d8

Please sign in to comment.