Skip to content

Commit

Permalink
Merge pull request #89 from appuio/allow-managing-machinesets
Browse files Browse the repository at this point in the history
Allow managing raw `MachineSets`
  • Loading branch information
bastjan authored Oct 31, 2024
2 parents 063dce5 + 183140b commit 3c72974
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 1 deletion.
2 changes: 2 additions & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ parameters:

nodeGroups: {}

machineSets: {}

machineConfigPools:
infra: {}
app: {}
Expand Down
9 changes: 8 additions & 1 deletion component/machine-sets.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,18 @@ local machineSpecs = [
if isGCP && isMultiAz(name)
]);

local additionalMachineSets = com.generateResources(params.machineSets, function(name) kube._Object('machine.openshift.io/v1beta1', 'MachineSet', name) {
metadata+: {
namespace: params.machineApiNamespace,
},
});

{
['machineset-' + m.name]: machineSet(m.name, m.spec)
for m in machineSpecs
if m.spec != null
} + {
[if std.length(machineSpecs) == 0 then '.gitkeep']: {},
[if std.length(machineSpecs) == 0 && std.length(additionalMachineSets) == 0 then '.gitkeep']: {},
} + {
[if std.length(additionalMachineSets) > 0 then 'additional_machine_sets']: additionalMachineSets,
}
58 changes: 58 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,64 @@ See the documentation for http://localhost:2020/cilium/references/parameters.htm

The script expects the ConfigMap to have a key matching each node name on which egress dummy interfaces should be configured.


== `machineSets`

[horizontal]
type:: dictionary
default:: `{}`
example::
+
[source,yaml]
----
machineSets:
worker:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
spec:
deletePolicy: Oldest
replicas: 3
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machineset: worker
template:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machine-role: app
machine.openshift.io/cluster-api-machine-type: app
machine.openshift.io/cluster-api-machineset: worker
spec:
lifecycleHooks: {}
metadata:
labels:
node-role.kubernetes.io/app: ""
node-role.kubernetes.io/worker: ""
providerSpec:
value:
antiAffinityKey: worker
baseDomain: c-cluster-1.vshnmanaged.net
flavor: plus-16-4
image: custom:rhcos-4.16
interfaces:
- addresses:
- subnetUUID: 1971d4c3-0065-41fc-82f4-c26cf2fe4f9a
type: Private
rootVolumeSizeGB: 100
tokenSecret:
name: cloudscale-rw-token
userDataSecret:
name: cloudscale-user-data
zone: lpg1
----

A dictionary of machine sets to create on the cluster.
The resulting `MachineSet` object will have the key as the name and the value is merged into the resource.

The MachineSet will will have the namespace from `machine_api_namespace` applied.

=== Example

[source,yaml]
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: machine.openshift.io/v1beta1
kind: MachineSet
metadata:
annotations: {}
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
name: worker
name: worker
namespace: openshift-machine-api
spec:
deletePolicy: Oldest
replicas: 3
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machineset: worker
template:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machine-role: app
machine.openshift.io/cluster-api-machine-type: app
machine.openshift.io/cluster-api-machineset: worker
spec:
lifecycleHooks: {}
metadata:
labels:
node-role.kubernetes.io/app: ''
node-role.kubernetes.io/worker: ''
providerSpec:
value:
antiAffinityKey: worker
baseDomain: c-cluster-1.vshnmanaged.net
flavor: plus-16-4
image: custom:rhcos-4.16
interfaces:
- addresses:
- subnetUUID: 1971d4c3-0065-41fc-82f4-c26cf2fe4f9a
type: Private
rootVolumeSizeGB: 100
tokenSecret:
name: cloudscale-rw-token
userDataSecret:
name: cloudscale-user-data
zone: lpg1
42 changes: 42 additions & 0 deletions tests/machineconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,45 @@ parameters:
egressInterfaces:
machineConfigPools:
- infra

machineSets:
worker:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
spec:
deletePolicy: Oldest
replicas: 3
selector:
matchLabels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machineset: worker
template:
metadata:
labels:
machine.openshift.io/cluster-api-cluster: c-cluster-1
machine.openshift.io/cluster-api-machine-role: app
machine.openshift.io/cluster-api-machine-type: app
machine.openshift.io/cluster-api-machineset: worker
spec:
lifecycleHooks: {}
metadata:
labels:
node-role.kubernetes.io/app: ""
node-role.kubernetes.io/worker: ""
providerSpec:
value:
antiAffinityKey: worker
baseDomain: c-cluster-1.vshnmanaged.net
flavor: plus-16-4
image: custom:rhcos-4.16
interfaces:
- addresses:
- subnetUUID: 1971d4c3-0065-41fc-82f4-c26cf2fe4f9a
type: Private
rootVolumeSizeGB: 100
tokenSecret:
name: cloudscale-rw-token
userDataSecret:
name: cloudscale-user-data
zone: lpg1

0 comments on commit 3c72974

Please sign in to comment.