Skip to content

Instantly share code, notes, and snippets.

@salaboy
Created July 19, 2023 19:09
Show Gist options
  • Save salaboy/125bc7a87c78cd5fb8c6654f5ef83fd7 to your computer and use it in GitHub Desktop.
Save salaboy/125bc7a87c78cd5fb8c6654f5ef83fd7 to your computer and use it in GitHub Desktop.
apiVersion: salaboy.com/v1alpha1
kind: Environment
metadata:
name: team-a-dev-env
spec:
compositionSelector:
matchLabels:
type: development
parameters:
infraInstall: true
---
apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
name: xenvironments.salaboy.com
spec:
group: salaboy.com
names:
kind: XEnvironment
plural: xenvironments
shortNames:
- "xenv"
- "xenvs"
claimNames:
kind: Environment
plural: environments
shortNames:
- "env"
- "envs"
versions:
- additionalPrinterColumns:
- jsonPath: .spec.parameters.database
name: DB
type: boolean
name: v1alpha1
served: true
referenceable: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
parameters:
type: object
properties:
infraInstall:
type: boolean
required:
required:
- parameters
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: dev.env.salaboy.com
labels:
type: development
spec:
writeConnectionSecretsToNamespace: crossplane-system
compositeTypeRef:
apiVersion: salaboy.com/v1alpha1
kind: XEnvironment
resources:
- name: vcluster-helm-release
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
annotations:
crossplane.io/external-name: # patched
spec:
rollbackLimit: 3
forProvider:
namespace: # patched
chart:
name: vcluster
repository: https://charts.loft.sh
version: "0.15.0-alpha.0"
values:
fallbackHostDns: true
multiNamespaceMode:
enabled: false
sync:
syncer:
extraArgs: [] # patched
# - --out-kube-config-server=https://cluster-1.cluster-1.svc
providerConfigRef:
name: default
patches:
- fromFieldPath: metadata.name
toFieldPath: spec.forProvider.namespace
policy:
fromFieldPath: Required
- fromFieldPath: metadata.name
toFieldPath: metadata.annotations[crossplane.io/external-name]
policy:
fromFieldPath: Required
- fromFieldPath: metadata.name
toFieldPath: metadata.name
transforms:
- type: string
string:
fmt: "%s-vcluster"
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.name
strategy: string
string:
fmt: "--out-kube-config-secret=%s-secret"
toFieldPath: spec.forProvider.values.syncer.extraArgs[0]
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.name
- fromFieldPath: metadata.name
strategy: string
string:
fmt: "--out-kube-config-server=https://%s.%s.svc"
toFieldPath: spec.forProvider.values.syncer.extraArgs[1]
- type: CombineFromComposite
combine:
variables:
- fromFieldPath: metadata.name
- fromFieldPath: metadata.name
strategy: string
string:
fmt: "--tls-san=%s.%s.svc"
toFieldPath: spec.forProvider.values.syncer.extraArgs[2]
readinessChecks:
- type: MatchString
fieldPath: status.atProvider.state
matchString: deployed
- name: helm-providerconfig
base:
apiVersion: helm.crossplane.io/v1alpha1
kind: ProviderConfig
spec:
credentials:
source: Secret
secretRef:
name: # patched
namespace: # patched
key: config
patches:
- fromFieldPath: metadata.name
toFieldPath: spec.credentials.secretRef.name
transforms:
- type: string
string:
fmt: vc-%s
- fromFieldPath: metadata.name
toFieldPath: spec.credentials.secretRef.namespace
- fromFieldPath: metadata.name
toFieldPath: metadata.name
readinessChecks:
- type: None
- name: app-chart-vcluster
base:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
annotations:
crossplane.io/external-name: conference-app
spec:
forProvider:
chart:
name: conference-app
repository: oci://docker.io/salaboy
version: "v1.0.0"
values:
install:
infrastructure: #patched
namespace: default
providerConfigRef:
name: #patched
patches:
- fromFieldPath: metadata.name
toFieldPath: spec.providerConfigRef.name
- fromFieldPath: spec.parameters.infraInstall
toFieldPath: spec.forProvider.values.install.infrastructure
readinessChecks:
- type: MatchString
fieldPath: status.atProvider.state
matchString: deployed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment