-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathhcpCluster-models.tsp
765 lines (621 loc) · 21.6 KB
/
hcpCluster-models.tsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
import "@typespec/rest";
import "@typespec/http";
import "@azure-tools/typespec-azure-core";
import "@azure-tools/typespec-azure-resource-manager";
using TypeSpec.Rest;
using TypeSpec.Http;
using Azure.Core;
using Azure.ResourceManager;
namespace Microsoft.RedHatOpenShift;
/*
* ===================================
* HCP cluster core resources
* ===================================
*/
/** HCP cluster resource */
model HcpOpenShiftClusterResource
is TrackedResource<HcpOpenShiftClusterProperties> {
/** Name of HCP cluster */
@pattern("^[a-zA-Z][a-zA-Z0-9-]$")
@minLength(3)
@maxLength(54)
@key("hcpOpenShiftClusterName") // sets the alternative name for the name propery
@path
@segment("hcpOpenShiftClusters")
name: string;
...ManagedServiceIdentityProperty;
}
// The NodePool needs to be TrackedResource for the following reasons:
// - allow tags to be in place, which allows billing to use tags, important for workers
// - allow nodepool to be tracked in the portal
// - deleted when resource group is deleted
// - allow cascade delete
// more: https://armwiki.azurewebsites.net/rp_onboarding/tracked_vs_proxy_resources.html
@parentResource(HcpOpenShiftClusterResource)
model HcpOpenShiftClusterNodePoolResource
is TrackedResource<NodePoolProperties> {
/** Name of HCP cluster * */
@pattern("^[a-zA-Z][a-zA-Z0-9-]$")
@minLength(3)
@maxLength(15)
@key("nodePoolName")
@path
@segment("nodePools")
name: string;
...ManagedServiceIdentityProperty;
}
/** HCP cluster properties */
model HcpOpenShiftClusterProperties {
/** The status of the last operation. */
@visibility("read")
provisioningState?: ProvisioningState;
/** The cluster resource specification. */
spec?: ClusterSpec;
}
/** HCP patchable cluster properties */
model HcpOpenShiftClusterPatchProperties {
/** The status of the last operation. */
@visibility("read")
provisioningState?: ProvisioningState;
/** The cluster resource specification. */
spec?: ClusterPatchSpec;
}
model ManagedServiceIdentityUpdate
is OptionalProperties<UpdateableProperties<Azure.ResourceManager.Foundations.ManagedServiceIdentity>>;
model HcpOpenShiftClusterPatch
is OptionalProperties<UpdateableProperties<OmitProperties<
HcpOpenShiftClusterResource,
"name" | "properties" | "identity"
>>> {
/** HCP patchable cluster properties */
properties?: HcpOpenShiftClusterPatchProperties;
/** Managed service identity */
identity?: ManagedServiceIdentityUpdate;
}
model HcpOpenShiftClusterNodePoolPatch
is OptionalProperties<UpdateableProperties<OmitProperties<
HcpOpenShiftClusterNodePoolResource,
"name" | "properties" | "identity"
>>> {
/** Represents the patchable node pool properties */
properties?: NodePoolPatchProperties;
/** Managed Service Identity */
identity?: ManagedServiceIdentityUpdate;
}
/** The cluster resource specification */
model ClusterSpec {
/** Version of the control plane components */
@visibility("create", "read")
version: VersionProfile;
/** Cluster DNS configuration */
dns?: DnsProfile;
/** Cluster network configuration */
@visibility("create", "read")
network?: NetworkProfile;
/** Shows the cluster web console information */
@visibility("read")
console: ConsoleProfile;
/** Shows the cluster API server profile */
@visibility("read")
api: ApiProfile;
/** Enable FIPS mode for the cluster
* When set to true, `etcdEncryption` must be set to true
*/
@visibility("create", "read")
fips?: boolean = false;
/** Enables customer ETCD encryption, set during creation
* When set to true, `platform.etcdEncryptionSetId` must be set
*/
@visibility("create", "read")
etcdEncryption?: boolean = false;
/** Disable user workload monitoring */
@visibility("create", "update")
disableUserWorkloadMonitoring?: boolean = false;
/** Openshift cluster proxy configuration */
@visibility("create", "update")
proxy?: ProxyProfile;
/** Azure platform configuration */
@visibility("create", "read")
platform?: PlatformProfile;
/** URL for the OIDC provider to be used for authentication
* to authenticate against user Azure cloud account
*/
@visibility("read")
issuerUrl: url;
/** Configuration to override the openshift-oauth-apiserver inside cluster
* This changes user login into the cluster to external provider
*/
@visibility("create", "read")
externalAuth?: ExternalAuthConfigProfile;
}
/** The patchable cluster specification */
model ClusterPatchSpec {
/** Disable user workload monitoring */
@visibility("update")
disableUserWorkloadMonitoring?: boolean;
/** Openshift cluster proxy configuration */
@visibility("update")
proxy?: ProxyProfile;
}
/** The resource provisioning state. */
@lroStatus
union ProvisioningState {
string,
ResourceProvisioningState,
/** Non-terminal state indicating the resource has been accepted */
"Accepted",
/** Non-terminal state indicating the resource is deleting */
"Deleting",
/** Non-terminal state indicating the resource is provisioning */
"Provisioning",
/** Non-terminal state indicating the resource is updating */
"Updating",
}
/** Versions represents an OpenShift version. */
model VersionProfile {
/** ID is the unique identifier of the version. */
@visibility("create", "read")
id: string;
/** ChannelGroup is the name of the set to which this version belongs. Each version belongs to only a single set. */
@visibility("create", "read")
channelGroup: string;
/** AvailableUpgrades is a list of version names the current version can be upgraded to. */
@visibility("read")
availableUpgrades: string[];
}
/** DNS contains the DNS settings of the cluster */
model DnsProfile {
/** BaseDomain is the base DNS domain of the cluster. */
@visibility("read")
baseDomain?: string;
/** BaseDomainPrefix is the unique name of the cluster representing the OpenShift's cluster name.
* BaseDomainPrefix is the name that will appear in the cluster's DNS, provisioned cloud providers resources
* */
@visibility("create", "read")
@maxLength(15)
@pattern(
"^[a-z]([-a-z0-9]*[a-z0-9])?$",
"Alphanumerics, underscores, and hyphens. Must start and end with an alphanumeric."
)
baseDomainPrefix?: string;
}
/** Network profile of the cluster */
model NetworkProfile {
/** The main controller responsible for rendering the core networking components */
@visibility("create", "read")
networkType?: NetworkType = NetworkType.OVNKubernetes;
/** The CIDR of the pod IP addresses
* example: 10.128.0.0/14
*/
@visibility("create", "read")
podCidr: string;
/** The CIDR block for assigned service IPs,
* example: 172.30.0.0/16
*/
@visibility("create", "read")
serviceCidr: string;
/** from which to assign machine IP addresses,
* example: 10.0.0.0/16
*/
@visibility("create", "read")
machineCidr: string;
/** Network host prefix which is defaulted to 23 if not specified. */
@visibility("create", "read")
hostPrefix?: int32 = 23;
}
/** The cluster network type */
union NetworkType {
string,
/** THE OVN network plugin for the OpenShift cluster */
OVNKubernetes: "OVNKubernetes",
/** Other network plugins */
Other: "Other",
}
/** Configuration of the cluster web console */
model ConsoleProfile {
/** The cluster web console URL endpoint */
@visibility("read")
url: url;
}
/** Information about the API of a cluster. */
model ApiProfile {
/** URL endpoint for the API server */
@visibility("read")
url: url;
/** should the API server be accessible from the internet */
@visibility("create", "read")
visibility: Visibility;
}
/** The visibility of the API server */
union Visibility {
string,
/** The API server is visible from the internet. */
public: "public",
/** The API server is not visible from the internet. */
private: "private",
}
/** OpenShift cluster proxy configuration */
model ProxyProfile {
/** http proxy config */
httpProxy?: url;
/** https proxy config */
httpsProxy?: url;
/** no proxy config */
noProxy?: string;
/** The trusted CA for the proxy */
trustedCa?: string;
}
/** Azure specific configuration */
model PlatformProfile {
/** Resource group to put cluster resources */
managedResourceGroup?: string;
/** ResourceId for the subnet used by the control plane */
subnetId: SubnetResourceId;
/** The core outgoing configuration */
outboundType?: OutboundType = OutboundType.loadBalancer;
/** ResourceId for the network security group attached to the cluster subnet */
networkSecurityGroupId?: NetworkSecurityGroupResourceId;
/** The id of the disk encryption set to be used for etcd.
* Configure this when `etcdEncryption` is set to true
* Is used the https://learn.microsoft.com/en-us/azure/storage/common/customer-managed-keys-overview
*/
etcdEncryptionSetId?: string;
/** The configuration that the operators of the cluster have to authenticate to Azure */
operatorsAuthentication: OperatorsAuthenticationProfile;
}
scalar SubnetResourceId
extends Azure.Core.armResourceIdentifier<[
{
type: "Microsoft.Network/virtualNetworks/subnets",
}
]>;
scalar NetworkSecurityGroupResourceId
extends Azure.Core.armResourceIdentifier<[
{
type: "Microsoft.Network/networkSecurityGroups",
}
]>;
/** The outbound routing strategy used to provide your cluster egress to the internet. */
union OutboundType {
string,
/** The load balancer configuration */
loadBalancer: "loadBalancer",
}
/** The configuration that the operators of the cluster have to authenticate to Azure. */
model OperatorsAuthenticationProfile {
/** Represents the information related to Azure User-Assigned managed identities needed
* to perform Operators authentication based on Azure User-Assigned Managed Identities */
userAssignedIdentities: UserAssignedIdentitiesProfile;
}
/** Represents the information related to Azure User-Assigned managed identities needed
* to perform Operators authentication based on Azure User-Assigned Managed Identities */
model UserAssignedIdentitiesProfile {
/** The set of Azure User-Assigned Managed Identities leveraged for the Control Plane
* operators of the cluster. The set of required managed identities is dependent on the
* Cluster's OpenShift version. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "operator name to user assigned identity pairings"
controlPlaneOperators: Record<UserAssignedIdentityResourceId>;
/** The set of Azure User-Assigned Managed Identities leveraged for the Data Plane
* operators of the cluster. The set of required managed identities is dependent on the
* Cluster's OpenShift version. */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" "operator name to user assigned identity pairings"
dataPlaneOperators: Record<UserAssignedIdentityResourceId>;
/** Represents the information associated to an Azure User-Assigned Managed Identity whose
* purpose is to perform service level actions. */
@visibility("create", "read")
serviceManagedIdentity: UserAssignedIdentityResourceId;
}
scalar UserAssignedIdentityResourceId
extends Azure.Core.armResourceIdentifier<[
{
type: "Microsoft.ManagedIdentity/userAssignedIdentities",
}
]>;
/*
* =======================================
* End HCP cluster core resources
* =======================================
*/
/*
* =======================================
* ExternalAuth resources
* =======================================
*/
/** External authentication configuration profile */
model ExternalAuthConfigProfile {
/** This can be set during cluster creation only to ensure there is no openshift-oauth-apiserver in cluster */
@visibility("create", "read")
enabled?: boolean = false;
/** This can only be set as a day-2 resource on a separate endpoint to provide a self-managed auth service */
@visibility("read")
@OpenAPI.extension("x-ms-identifiers", ["issuer", "clients", "claim"])
externalAuths: ExternalAuthProfile[];
}
/** External authentication profile */
model ExternalAuthProfile {
/** Token Issuer profile */
issuer: TokenIssuerProfile;
/** External auth clients */
clients: ExternalAuthClientProfile[];
/** External auth claim */
claim: ExternalAuthClaimProfile;
}
/** Token issuer profile */
model TokenIssuerProfile {
/** The URL of the token issuer */
url: url;
/** The audience of the token issuer */
audiences: string[];
/** The issuer of the token */
ca: string;
}
/** External auth client profile */
model ExternalAuthClientProfile {
/** External auth client component */
component: ExternalAuthClientComponentProfile;
/** external auth client id */
id: string;
/** external auth client secret */
@secret
secret: string;
/** external auth client scopes */
extraScopes: string[];
}
/** External auth component profile */
model ExternalAuthClientComponentProfile {
/** The name of the external auth client */
name: string;
/** The namespace of the external auth client */
authClientNamespace: string;
}
/** External auth claim profile */
model ExternalAuthClaimProfile {
/** The claim mappings */
mappings: TokenClaimMappingsProfile;
/** The claim validation rules */
@OpenAPI.extension("x-ms-identifiers", ["claim", "requiredValue"])
validationRules: TokenClaimValidationRuleProfile[];
}
/** External auth claim mappings profile */
model TokenClaimMappingsProfile {
/** The claim mappings username */
username: ClaimProfile;
/** The claim mappings groups */
groups: ClaimProfile;
}
/** External auth claim profile */
model ClaimProfile {
/** Claim name of the external profile */
claim: string;
/** Prefix for the claim external profile */
prefix: string;
/** Prefix policy */
prefixPolicy: string;
}
/** External auth claim validation rule */
model TokenClaimValidationRuleProfile {
/** Claim name for the validation profile */
claim: string;
/** Required value */
requiredValue: string;
}
/*
* =======================================
* End ExternalAuth resources
* =======================================
*/
/*
* =======================================
* NodePool resources
* =======================================
*/
/** Represents the node pool properties */
model NodePoolProperties {
/** Provisioning state */
@visibility("read")
provisioningState?: ProvisioningState;
/** The node pool resource specification */
spec?: NodePoolSpec;
}
/** Represents the patchable node pool properties */
model NodePoolPatchProperties {
/** Provisioning state */
@visibility("read")
provisioningState?: ResourceProvisioningState;
/** The node pool resource specification */
spec?: NodePoolPatchSpec;
}
/** taintKey is the k8s valid key of the taint type on the nodepool nodes
* The good example of the taint key is `node-role.kubernetes.io/master`
*/
@minLength(1)
@maxLength(316)
scalar taintKey extends string;
/** taintValue is the k8s valid value of the taint type on the nodepool nodes
* The good example of the taint value is `NoSchedule`
*/
@minLength(1)
@maxLength(63)
scalar taintValue extends string;
/** The taint effect the same as in K8s */
union Effect {
string,
/** NoSchedule taint effect */
NoSchedule: "NoSchedule",
/** PreferNoSchedule taint effect */
PreferNoSchedule: "PreferNoSchedule",
/** NoExecute taint effect */
NoExecute: "NoExecute",
}
/** Worker node pool profile */
model NodePoolSpec {
/** OpenShift version for the nodepool */
@visibility("create", "read")
version: VersionProfile;
/** Azure node pool platform configuration */
@visibility("create")
platform: NodePoolPlatformProfile;
/** The number of worker nodes, it cannot be used together with autoscaling */
@visibility("create", "update")
replicas?: int32;
/** Auto-repair */
@visibility("create", "read")
autoRepair?: boolean = false;
/** Representation of a autoscaling in a node pool. */
autoScaling?: NodePoolAutoScaling;
// This warning means to ensure good customer experience, to not create
// poorly defined types. However here the type literarly is the map<string, value>
/** K8s labels to propagate to the NodePool Nodes
* The good example of the label is `node-role.kubernetes.io/master: ""`
*/
#suppress "@azure-tools/typespec-azure-resource-manager/arm-no-record" ""
@visibility("create", "update")
@OpenAPI.extension("x-ms-identifiers", ["key", "value"])
labels?: Label[];
/** Taints for the nodes */
@visibility("create", "update")
@OpenAPI.extension("x-ms-identifiers", ["key", "value", "effect"])
taints?: Taint[];
/*
* The Tuned API is defined here:
* - https://github.com/openshift/cluster-node-tuning-operator/blob/2c76314fb3cc8f12aef4a0dcd67ddc3677d5b54f/pkg/apis/tuned/v1/tuned_types.go
*
* The PerformanceProfile API is defined here:
* - https://github.com/openshift/cluster-node-tuning-operator/tree/b41042d42d4ba5bb2e99960248cf1d6ae4935018/pkg/apis/performanceprofile/v2
*/
/** Tuning configs, TODO provide meaningful explanation
* TuningConfig is a list of references to ConfigMaps containing serialized
* Tuned resources to define the tuning configuration to be applied to
* nodes in the NodePool.
* Each ConfigMap must have a single key named "tuned" whose value is the
* JSON or YAML of a serialized Tuned or PerformanceProfile.
*/
tuningConfigs?: string[];
}
/** Worker node pool profile */
model NodePoolPatchSpec {
/** The number of worker nodes, it cannot be used together with autoscaling */
@visibility("update")
replicas?: int32;
/** Representation of a autoscaling in a node pool. */
autoScaling?: NodePoolAutoScaling;
// This warning means to ensure good customer experience, to not create
// poorly defined types. However here the type literarly is the map<string, value>
/** K8s labels to propagate to the NodePool Nodes
* The good example of the label is `node-role.kubernetes.io/master: ""`
*/
@visibility("update")
@OpenAPI.extension("x-ms-identifiers", ["key", "value"])
labels?: Label[];
/** Taints for the nodes */
@visibility("update")
@OpenAPI.extension("x-ms-identifiers", ["key", "value", "effect"])
taints?: Taint[];
/*
* The Tuned API is defined here:
* - https://github.com/openshift/cluster-node-tuning-operator/blob/2c76314fb3cc8f12aef4a0dcd67ddc3677d5b54f/pkg/apis/tuned/v1/tuned_types.go
*
* The PerformanceProfile API is defined here:
* - https://github.com/openshift/cluster-node-tuning-operator/tree/b41042d42d4ba5bb2e99960248cf1d6ae4935018/pkg/apis/performanceprofile/v2
*/
/** Tuning configs, TODO provide meaningful explanation
* TuningConfig is a list of references to ConfigMaps containing serialized
* Tuned resources to define the tuning configuration to be applied to
* nodes in the NodePool.
* Each ConfigMap must have a single key named "tuned" whose value is the
* JSON or YAML of a serialized Tuned or PerformanceProfile.
*/
tuningConfigs?: string[];
}
/** Taint is controlling the node taint and its effects */
model Taint {
/** The key of the taint
* The good example of the taint key is `node-role.kubernetes.io/master`
*/
key?: taintKey;
/** The value of the taint
* The good example of the taint value is `NoSchedule`
*/
value?: taintValue;
/** The effect of the taint
* The good example of the taint effect is `NoSchedule`
*/
effect?: Effect;
}
/** Label represents the k8s label */
// Key and value are both optional, so there is no need to redefine them for PATCH
model Label {
/** The key of the label */
key?: string;
/** The value of the label */
value?: string;
}
/** Azure node pool platform configuration */
model NodePoolPlatformProfile {
/** The resourceId for the subnet used by the workers */
subnetId?: string;
/** The VM size according to the documentation:
* - https://learn.microsoft.com/en-us/azure/virtual-machines/sizes */
vmSize: string;
/** The OS disk size in GiB */
diskSizeGiB?: int32;
/** The type of the disk storage account
* - https://learn.microsoft.com/en-us/azure/virtual-machines/disks-types
*/
diskStorageAccountType?: string;
/** The availability zone for the node pool.
* Please read the documentation to see which regions support availability zones
* - https://learn.microsoft.com/en-us/azure/availability-zones/az-overview
*/
availabilityZone?: string;
/** Whether the worker machines should be encrypted at host */
encryptionAtHost?: boolean;
/** Disk Encryption Set ID that will be used for encryption the Nodes disks
* - https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption-overview
* - https://learn.microsoft.com/en-us/azure/virtual-machines/disk-encryption
*/
diskEncryptionSetId?: string;
/** Is the disk ephemeral */
ephemeralOsDisk?: boolean;
}
/** Node pool autoscaling */
model NodePoolAutoScaling {
/** The minimum number of nodes in the node pool */
@minValue(0)
min?: int32;
/** The maximum number of nodes in the node pool */
@minValue(0)
max?: int32;
}
/*
* =======================================
* End NodePool resources
* =======================================
*/
/*
* =======================================
* HCP cluster credentials
* =======================================
*/
/** HCP cluster credentials */
model HcpOpenShiftClusterCredentials {
/** kubeadmin user name */
@visibility("read")
kubeadminUsername: string;
/** kube admin password */
@visibility("read")
@secret
kubeadminPassword: string;
}
/** HCP cluster admin kubeconfig */
model HcpOpenShiftClusterKubeconfig {
/** The kubeconfig file */
@visibility("read")
@secret
kubeconfig: string;
}
/*
* =======================================
* End HCP cluster credentials
* =======================================
*/