or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

client-setup.mdconfiguration-management.mdcore-resources.mdindex.mdmachine-management.mdmonitoring.mdmulticluster-management.mdoperator-management.mdsecurity-rbac.md

machine-management.mddocs/

0

# Machine and Node Management

1

2

Machine lifecycle management and node configuration through machine.openshift.io and machineconfiguration.openshift.io API groups. Provides comprehensive control over cluster nodes, machine pools, and runtime configuration.

3

4

## Capabilities

5

6

### Machine API Management

7

8

OpenShift Machine API for managing the lifecycle of cluster nodes and machine resources.

9

10

```java { .api }

11

/**

12

* Access to Machine API Group (machine.openshift.io)

13

* Machine lifecycle and cluster node management

14

*/

15

OpenShiftMachineAPIGroupDSL machine();

16

17

interface OpenShiftMachineAPIGroupDSL {

18

/** Individual machine resources (v1beta1) */

19

MixedOperation<Machine, MachineList, Resource<Machine>> machines();

20

21

/** Machine set resources for grouped machine management (v1beta1) */

22

MixedOperation<MachineSet, MachineSetList, Resource<MachineSet>> machineSets();

23

24

/** Machine health monitoring and remediation (v1beta1) */

25

MixedOperation<MachineHealthCheck, MachineHealthCheckList, Resource<MachineHealthCheck>> machineHealthChecks();

26

27

/** Control plane machine sets (v1) */

28

NonNamespaceOperation<ControlPlaneMachineSet, ControlPlaneMachineSetList, Resource<ControlPlaneMachineSet>> controlPlaneMachineSets();

29

}

30

```

31

32

**Usage Examples:**

33

34

```java

35

// List all machines in cluster

36

MachineList machines = client.machine().machines()

37

.inNamespace("openshift-machine-api")

38

.list();

39

40

// Get specific machine details

41

Machine machine = client.machine().machines()

42

.inNamespace("openshift-machine-api")

43

.withName("my-cluster-worker-us-east-1a-abc123")

44

.get();

45

46

if (machine != null) {

47

String phase = machine.getStatus().getPhase();

48

String nodeName = machine.getStatus().getNodeRef().getName();

49

System.out.println("Machine " + nodeName + " is " + phase);

50

}

51

52

// Scale machine set

53

MachineSet machineSet = client.machine().machineSets()

54

.inNamespace("openshift-machine-api")

55

.withName("my-cluster-worker-us-east-1a")

56

.get();

57

58

if (machineSet != null) {

59

machineSet.getSpec().setReplicas(5);

60

client.machine().machineSets()

61

.inNamespace("openshift-machine-api")

62

.replace(machineSet);

63

}

64

65

// Create machine health check

66

MachineHealthCheck healthCheck = new MachineHealthCheckBuilder()

67

.withMetadata(new ObjectMetaBuilder()

68

.withName("worker-health-check")

69

.withNamespace("openshift-machine-api")

70

.build())

71

.withSpec(new MachineHealthCheckSpecBuilder()

72

.withSelector(new LabelSelectorBuilder()

73

.addToMatchLabels("machine.openshift.io/cluster-api-machine-role", "worker")

74

.build())

75

.withUnhealthyConditions(

76

new UnhealthyConditionBuilder()

77

.withType("Ready")

78

.withStatus("False")

79

.withTimeout("5m")

80

.build(),

81

new UnhealthyConditionBuilder()

82

.withType("Ready")

83

.withStatus("Unknown")

84

.withTimeout("5m")

85

.build())

86

.withMaxUnhealthy("40%")

87

.withNodeStartupTimeout("10m")

88

.build())

89

.build();

90

91

client.machine().machineHealthChecks()

92

.inNamespace("openshift-machine-api")

93

.create(healthCheck);

94

```

95

96

### Machine Configuration Management

97

98

Machine configuration management for node-level settings, container runtime, and kubelet configuration.

99

100

```java { .api }

101

/**

102

* Access to Machine Configuration API Group (machineconfiguration.openshift.io/v1)

103

* Node configuration and runtime management

104

*/

105

MachineConfigurationAPIGroupDSL machineConfigurations();

106

107

interface MachineConfigurationAPIGroupDSL {

108

/** Individual machine configurations */

109

NonNamespaceOperation<MachineConfig, MachineConfigList, Resource<MachineConfig>> machineConfigs();

110

111

/** Machine configuration pools for grouped node management */

112

NonNamespaceOperation<MachineConfigPool, MachineConfigPoolList, Resource<MachineConfigPool>> machineConfigPools();

113

114

/** Kubelet configuration settings */

115

NonNamespaceOperation<KubeletConfig, KubeletConfigList, Resource<KubeletConfig>> kubeletConfigs();

116

117

/** Container runtime configuration */

118

NonNamespaceOperation<ContainerRuntimeConfig, ContainerRuntimeConfigList, Resource<ContainerRuntimeConfig>> containerRuntimeConfigs();

119

120

/** Machine config controller configuration */

121

NonNamespaceOperation<ControllerConfig, ControllerConfigList, Resource<ControllerConfig>> controllerConfigs();

122

}

123

```

124

125

**Usage Examples:**

126

127

```java

128

// List machine config pools

129

MachineConfigPoolList pools = client.machineConfigurations().machineConfigPools().list();

130

131

// Get worker pool status

132

MachineConfigPool workerPool = client.machineConfigurations().machineConfigPools()

133

.withName("worker")

134

.get();

135

136

if (workerPool != null) {

137

int readyMachines = workerPool.getStatus().getReadyMachineCount();

138

int totalMachines = workerPool.getStatus().getMachineCount();

139

boolean updated = workerPool.getStatus().getConditions().stream()

140

.anyMatch(c -> "Updated".equals(c.getType()) && "True".equals(c.getStatus()));

141

142

System.out.println("Worker pool: " + readyMachines + "/" + totalMachines + " ready, updated: " + updated);

143

}

144

145

// Create custom kubelet configuration

146

KubeletConfig kubeletConfig = new KubeletConfigBuilder()

147

.withMetadata(new ObjectMetaBuilder()

148

.withName("custom-kubelet")

149

.build())

150

.withSpec(new KubeletConfigSpecBuilder()

151

.withMachineConfigPoolSelector(new LabelSelectorBuilder()

152

.addToMatchLabels("pools.operator.machineconfiguration.openshift.io/worker", "")

153

.build())

154

.withKubeletConfig(new ObjectNode(JsonNodeFactory.instance)

155

.put("maxPods", 500)

156

.put("podsPerCore", 0))

157

.build())

158

.build();

159

160

client.machineConfigurations().kubeletConfigs().create(kubeletConfig);

161

162

// Create container runtime configuration

163

ContainerRuntimeConfig runtimeConfig = new ContainerRuntimeConfigBuilder()

164

.withMetadata(new ObjectMetaBuilder()

165

.withName("custom-crio")

166

.build())

167

.withSpec(new ContainerRuntimeConfigSpecBuilder()

168

.withMachineConfigPoolSelector(new LabelSelectorBuilder()

169

.addToMatchLabels("pools.operator.machineconfiguration.openshift.io/worker", "")

170

.build())

171

.withContainerRuntimeConfig(new ContainerRuntimeConfigurationBuilder()

172

.withPidsLimit(4096L)

173

.build())

174

.build())

175

.build();

176

177

client.machineConfigurations().containerRuntimeConfigs().create(runtimeConfig);

178

```

179

180

### Autoscaling Management

181

182

Machine-level autoscaling configuration for dynamic cluster scaling based on workload demands.

183

184

```java { .api }

185

/**

186

* Access to OpenShift Autoscaling API Group (autoscaling.openshift.io)

187

* Cluster and machine autoscaling capabilities

188

*/

189

OpenShiftAutoscalingAPIGroupDSL openShiftAutoscaling();

190

191

interface OpenShiftAutoscalingAPIGroupDSL {

192

/** v1 autoscaling API access */

193

V1AutoscalingAPIGroupDSL v1();

194

195

/** v1beta1 autoscaling API access */

196

V1beta1AutoscalingAPIGroupDSL v1beta1();

197

}

198

199

interface V1AutoscalingAPIGroupDSL {

200

/** Cluster-wide autoscaling configuration */

201

NonNamespaceOperation<ClusterAutoscaler, ClusterAutoscalerList, Resource<ClusterAutoscaler>> clusterAutoscalers();

202

}

203

204

interface V1beta1AutoscalingAPIGroupDSL {

205

/** Machine-level autoscaling configuration */

206

MixedOperation<MachineAutoscaler, MachineAutoscalerList, Resource<MachineAutoscaler>> machineAutoscalers();

207

}

208

```

209

210

**Usage Examples:**

211

212

```java

213

// Configure cluster autoscaler

214

ClusterAutoscaler clusterAutoscaler = new ClusterAutoscalerBuilder()

215

.withMetadata(new ObjectMetaBuilder()

216

.withName("default")

217

.build())

218

.withSpec(new ClusterAutoscalerSpecBuilder()

219

.withPodPriorityThreshold(-10)

220

.withResourceLimits(new ResourceLimitsBuilder()

221

.withMaxNodesTotal(100)

222

.withCores(new ResourceRangeBuilder().withMin(8).withMax(400).build())

223

.withMemory(new ResourceRangeBuilder().withMin(4).withMax(1600).build())

224

.build())

225

.withScaleDown(new ScaleDownConfigBuilder()

226

.withEnabled(true)

227

.withDelayAfterAdd("10m")

228

.withDelayAfterDelete("10s")

229

.withDelayAfterFailure("3m")

230

.withUnneededTime("10m")

231

.build())

232

.build())

233

.build();

234

235

client.openShiftAutoscaling().v1().clusterAutoscalers().createOrReplace(clusterAutoscaler);

236

237

// Configure machine set autoscaling

238

MachineAutoscaler machineAutoscaler = new MachineAutoscalerBuilder()

239

.withMetadata(new ObjectMetaBuilder()

240

.withName("worker-us-east-1a")

241

.withNamespace("openshift-machine-api")

242

.build())

243

.withSpec(new MachineAutoscalerSpecBuilder()

244

.withMinReplicas(1)

245

.withMaxReplicas(10)

246

.withScaleTargetRef(new CrossVersionObjectReferenceBuilder()

247

.withApiVersion("machine.openshift.io/v1beta1")

248

.withKind("MachineSet")

249

.withName("my-cluster-worker-us-east-1a")

250

.build())

251

.build())

252

.build();

253

254

client.openShiftAutoscaling().v1beta1().machineAutoscalers()

255

.inNamespace("openshift-machine-api")

256

.create(machineAutoscaler);

257

```

258

259

## Usage Patterns

260

261

### Node Maintenance and Updates

262

263

```java

264

// Cordon and drain node for maintenance

265

Machine machine = client.machine().machines()

266

.inNamespace("openshift-machine-api")

267

.withName("my-cluster-worker-abc123")

268

.get();

269

270

if (machine != null) {

271

String nodeName = machine.getStatus().getNodeRef().getName();

272

273

// Cordon the node

274

Node node = client.nodes().withName(nodeName).get();

275

node.getSpec().setUnschedulable(true);

276

client.nodes().withName(nodeName).replace(node);

277

278

// Delete machine to trigger replacement

279

client.machine().machines()

280

.inNamespace("openshift-machine-api")

281

.withName("my-cluster-worker-abc123")

282

.delete();

283

}

284

```

285

286

### Machine Configuration Updates

287

288

```java

289

// Create machine config for custom files

290

MachineConfig customConfig = new MachineConfigBuilder()

291

.withMetadata(new ObjectMetaBuilder()

292

.withName("99-custom-config")

293

.withLabels(Map.of(

294

"machineconfiguration.openshift.io/role", "worker"

295

))

296

.build())

297

.withSpec(new MachineConfigSpecBuilder()

298

.withConfig(new IgnitionBuilder()

299

.withVersion("3.1.0")

300

.withStorage(new StorageBuilder()

301

.addNewFile()

302

.withPath("/etc/custom-app.conf")

303

.withMode(420) // 0644

304

.withContents(new ContentsBuilder()

305

.withSource("data:text/plain;base64,Y3VzdG9tIGNvbmZpZw==")

306

.build())

307

.endFile()

308

.build())

309

.build())

310

.build())

311

.build();

312

313

client.machineConfigurations().machineConfigs().create(customConfig);

314

```