generated from crossplane-contrib/provider-jet-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add k3s server + agent example composition
Signed-off-by: Marques Johansson <[email protected]>
- Loading branch information
Showing
3 changed files
with
168 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: Composition | ||
metadata: | ||
name: k3sclusters.deployments.equinix.com | ||
spec: | ||
writeConnectionSecretsToNamespace: crossplane-system | ||
compositeTypeRef: | ||
apiVersion: deployments.equinix.com/v1alpha1 | ||
kind: K3sCluster | ||
resources: | ||
- name: k3s-project | ||
base: | ||
apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 | ||
kind: Project | ||
patches: | ||
- type: FromCompositeFieldPath | ||
fromFieldPath: metadata.name | ||
toFieldPath: spec.forProvider.name | ||
- name: k3s-server | ||
base: | ||
apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 | ||
kind: Device | ||
metadata: | ||
labels: | ||
k3s-server: 'true' | ||
spec: | ||
forProvider: | ||
hostname: k3s-server | ||
plan: c3.small.x86 | ||
operatingSystem: ubuntu_20_04 | ||
billingCycle: hourly | ||
locked: false | ||
networkType: hybrid | ||
tags: | ||
- crossplane | ||
projectIdSelector: | ||
matchControllerRef: true | ||
writeConnectionSecretToRef: | ||
name: server | ||
namespace: crossplane-system | ||
reclaimPolicy: Delete | ||
patches: | ||
- type: ToCompositeFieldPath | ||
fromFieldPath: status.atProvider.accessPublicIpv4 | ||
toFieldPath: status.serverIP | ||
- type: FromCompositeFieldPath | ||
fromFieldPath: spec.metro | ||
toFieldPath: spec.forProvider.metro | ||
- type: CombineFromComposite | ||
toFieldPath: spec.forProvider.userdata | ||
combine: | ||
variables: | ||
- fromFieldPath: spec.k3stoken | ||
strategy: string | ||
string: | ||
fmt: | | ||
#cloud-config | ||
write_files: | ||
#- permissions: '0660' | ||
# path: /etc/rancher/k3s/config.yaml | ||
# content: | | ||
# # k3s config | ||
runcmd: | ||
- sudo apt update | ||
- sudo apt upgrade -y | ||
- curl -sfL https://get.k3s.io | \ | ||
INSTALL_K3S_EXEC="server" \ | ||
K3S_TOKEN="%s" sh - | ||
- name: k3s-agent | ||
base: | ||
apiVersion: metal.equinix.jet.crossplane.io/v1alpha1 | ||
kind: Device | ||
metadata: | ||
labels: | ||
k3s-agent: 'true' | ||
spec: | ||
forProvider: | ||
hostname: k3s-agent | ||
plan: c3.small.x86 | ||
operatingSystem: ubuntu_20_04 | ||
billingCycle: hourly | ||
locked: false | ||
networkType: hybrid | ||
tags: | ||
- crossplane | ||
projectIdSelector: | ||
matchControllerRef: true | ||
writeConnectionSecretToRef: | ||
name: crossplane-conformance | ||
namespace: crossplane-system | ||
reclaimPolicy: Delete | ||
patches: | ||
# TODO we reuse metro patches. create a 'patchtype' | ||
- type: FromCompositeFieldPath | ||
fromFieldPath: spec.metro | ||
toFieldPath: spec.forProvider.metro | ||
- type: CombineFromComposite | ||
toFieldPath: spec.forProvider.userdata | ||
policy: | ||
fromFieldPath: Required | ||
combine: | ||
variables: | ||
- fromFieldPath: spec.k3stoken | ||
- fromFieldPath: status.serverIP | ||
strategy: string | ||
string: | ||
fmt: | | ||
#cloud-config | ||
write_files: | ||
#- permissions: '0660' | ||
# path: /etc/rancher/k3s/config.yaml | ||
# content: | | ||
# # k3s config | ||
runcmd: | ||
- sudo apt update | ||
- sudo apt upgrade -y | ||
- curl -sfL https://get.k3s.io | \ | ||
K3S_TOKEN="%s" \ | ||
K3S_URL=https://%s:6443 sh - | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
apiVersion: apiextensions.crossplane.io/v1 | ||
kind: CompositeResourceDefinition | ||
metadata: | ||
name: k3sclusters.deployments.equinix.com | ||
spec: | ||
group: deployments.equinix.com | ||
names: | ||
kind: K3sCluster | ||
listKind: K3sClusterList | ||
plural: k3sclusters | ||
singular: k3scluster | ||
versions: | ||
- name: v1alpha1 | ||
served: true | ||
referenceable: true | ||
schema: | ||
openAPIV3Schema: | ||
description: Managed resources for provider-jet-equinix crossplane K3s Cluster. Creates a k3s server and agent node in a new project named after the composition resource. | ||
type: object | ||
properties: | ||
spec: | ||
type: object | ||
properties: | ||
metro: | ||
type: string | ||
description: metro | ||
k3stoken: | ||
type: string | ||
description: K3s Token | ||
required: | ||
- metro | ||
- k3stoken | ||
status: | ||
type: object | ||
properties: | ||
serverIP: | ||
type: string | ||
description: IPv4 of the K3s Server | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: deployments.equinix.com/v1alpha1 | ||
kind: K3sCluster | ||
metadata: | ||
name: k3s-sv | ||
spec: | ||
metro: sv | ||
k3stoken: t09s3cr37 # This is an example token. |