Skip to content

Commit

Permalink
Merge pull request #97 from Peefy/cluster-api-provider-vsphere-module
Browse files Browse the repository at this point in the history
feat: add cluster-api-provider-vsphere-module modules and crd to kcl scripts.
  • Loading branch information
Peefy authored Dec 11, 2023
2 parents d6cb096 + 440c0f7 commit 539fdad
Show file tree
Hide file tree
Showing 71 changed files with 34,591 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,16 @@ description = "This is my module."

**At the same time, you cannot upload the same version module multiple times.** Once the version number of your module has been used, you will not be able to use this version number again. The only way to upload this module again is to upgrade the version number.

## Other Usages

### Convert Kubernetes CRD to KCL Modules

```shell
./scripts/crd_to_kcl <github repo>
```

For example

```shell
./scripts/crd_to_kcl.sh github.com/kubernetes-sigs/cluster-api-provider-vsphere
```
17,267 changes: 17,267 additions & 0 deletions cluster-api-provider-vsphere/crds/cluster-api-provider-vsphere.yaml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions cluster-api-provider-vsphere/kcl.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "cluster-api-provider-vsphere"
edition = "0.0.1"
version = "0.0.1"

[dependencies]
k8s = "1.28"
9 changes: 9 additions & 0 deletions cluster-api-provider-vsphere/kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[dependencies]
[dependencies.k8s]
name = "k8s"
full_name = "k8s_1.28"
version = "1.28"
sum = "aTxPUVZyr9MdiB3YdiY/8pCh9sC55yURnZdGlJsKG6Q="
reg = "ghcr.io"
repo = "kcl-lang/k8s"
oci_tag = "1.28"
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""
import regex
import k8s.apimachinery.pkg.apis.meta.v1


schema BGPConfiguration:
"""
BGPConfiguration contains the configuration for any BGP routing.

Attributes
----------
apiVersion : str, default is "crd.projectcalico.org/v1", required
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind : str, default is "BGPConfiguration", required
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata : v1.ObjectMeta, default is Undefined, optional
metadata
spec : CrdProjectcalicoOrgV1BGPConfigurationSpec, default is Undefined, optional
spec
"""


apiVersion: "crd.projectcalico.org/v1" = "crd.projectcalico.org/v1"

kind: "BGPConfiguration" = "BGPConfiguration"

metadata?: v1.ObjectMeta

spec?: CrdProjectcalicoOrgV1BGPConfigurationSpec


schema CrdProjectcalicoOrgV1BGPConfigurationSpec:
"""
BGPConfigurationSpec contains the values of the BGP configuration.

Attributes
----------
asNumber : int, default is Undefined, optional
ASNumber is the default AS number used by a node. [Default: 64512]
bindMode : str, default is Undefined, optional
BindMode indicates whether to listen for BGP connections on all addresses (None) or only on the node's canonical IP address Node.Spec.BGP.IPvXAddress (NodeIP). Default behaviour is to listen for BGP connections on all addresses.
communities : [CrdProjectcalicoOrgV1BGPConfigurationSpecCommunitiesItems0], default is Undefined, optional
Communities is a list of BGP community values and their arbitrary names for tagging routes.
listenPort : int, default is Undefined, optional
ListenPort is the port where BGP protocol should listen. Defaults to 179
logSeverityScreen : str, default is Undefined, optional
LogSeverityScreen is the log severity above which logs are sent to the stdout. [Default: INFO]
nodeMeshMaxRestartTime : str, default is Undefined, optional
Time to allow for software restart for node-to-mesh peerings. When specified, this is configured as the graceful restart timeout. When not specified, the BIRD default of 120s is used. This field can only be set on the default BGPConfiguration instance and requires that NodeMesh is enabled
nodeMeshPassword : CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPassword, default is Undefined, optional
node mesh password
nodeToNodeMeshEnabled : bool, default is Undefined, optional
NodeToNodeMeshEnabled sets whether full node to node BGP mesh is enabled. [Default: true]
prefixAdvertisements : [CrdProjectcalicoOrgV1BGPConfigurationSpecPrefixAdvertisementsItems0], default is Undefined, optional
PrefixAdvertisements contains per-prefix advertisement configuration.
serviceClusterIPs : [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceClusterIPsItems0], default is Undefined, optional
ServiceClusterIPs are the CIDR blocks from which service cluster IPs are allocated. If specified, Calico will advertise these blocks, as well as any cluster IPs within them.
serviceExternalIPs : [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceExternalIPsItems0], default is Undefined, optional
ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs. Kubernetes Service ExternalIPs will only be advertised if they are within one of these blocks.
serviceLoadBalancerIPs : [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceLoadBalancerIPsItems0], default is Undefined, optional
ServiceLoadBalancerIPs are the CIDR blocks for Kubernetes Service LoadBalancer IPs. Kubernetes Service status.LoadBalancer.Ingress IPs will only be advertised if they are within one of these blocks.
"""


asNumber?: int

bindMode?: str

communities?: [CrdProjectcalicoOrgV1BGPConfigurationSpecCommunitiesItems0]

listenPort?: int

logSeverityScreen?: str

nodeMeshMaxRestartTime?: str

nodeMeshPassword?: CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPassword

nodeToNodeMeshEnabled?: bool

prefixAdvertisements?: [CrdProjectcalicoOrgV1BGPConfigurationSpecPrefixAdvertisementsItems0]

serviceClusterIPs?: [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceClusterIPsItems0]

serviceExternalIPs?: [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceExternalIPsItems0]

serviceLoadBalancerIPs?: [CrdProjectcalicoOrgV1BGPConfigurationSpecServiceLoadBalancerIPsItems0]


check:
listenPort <= 65535
listenPort >= 1


schema CrdProjectcalicoOrgV1BGPConfigurationSpecCommunitiesItems0:
"""
Community contains standard or large community value and its name.

Attributes
----------
name : str, default is Undefined, optional
Name given to community value.
value : str, default is Undefined, optional
Value must be of format `aa:nn` or `aa:nn:mm`. For standard community use `aa:nn` format, where `aa` and `nn` are 16 bit number. For large community use `aa:nn:mm` format, where `aa`, `nn` and `mm` are 32 bit number. Where, `aa` is an AS Number, `nn` and `mm` are per-AS identifier.
"""


name?: str

value?: str


check:
regex.match(str(value), r"^(\d+):(\d+)$|^(\d+):(\d+):(\d+)$") if value


schema CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPassword:
"""
Optional BGP password for full node-to-mesh peerings. This field can only be set on the default BGPConfiguration instance and requires that NodeMesh is enabled

Attributes
----------
secretKeyRef : CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPasswordSecretKeyRef, default is Undefined, optional
secret key ref
"""


secretKeyRef?: CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPasswordSecretKeyRef


schema CrdProjectcalicoOrgV1BGPConfigurationSpecNodeMeshPasswordSecretKeyRef:
"""
Selects a key of a secret in the node pod's namespace.

Attributes
----------
key : str, default is Undefined, required
The key of the secret to select from. Must be a valid secret key.
name : str, default is Undefined, optional
Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?
optional : bool, default is Undefined, optional
Specify whether the Secret or its key must be defined
"""


key: str

name?: str

optional?: bool


schema CrdProjectcalicoOrgV1BGPConfigurationSpecPrefixAdvertisementsItems0:
"""
PrefixAdvertisement configures advertisement properties for the specified CIDR.

Attributes
----------
cidr : str, default is Undefined, optional
CIDR for which properties should be advertised.
communities : [str], default is Undefined, optional
Communities can be list of either community names already defined in `Specs.Communities` or community value of format `aa:nn` or `aa:nn:mm`. For standard community use `aa:nn` format, where `aa` and `nn` are 16 bit number. For large community use `aa:nn:mm` format, where `aa`, `nn` and `mm` are 32 bit number. Where,`aa` is an AS Number, `nn` and `mm` are per-AS identifier.
"""


cidr?: str

communities?: [str]


schema CrdProjectcalicoOrgV1BGPConfigurationSpecServiceClusterIPsItems0:
"""
ServiceClusterIPBlock represents a single allowed ClusterIP CIDR block.

Attributes
----------
cidr : str, default is Undefined, optional
cidr
"""


cidr?: str


schema CrdProjectcalicoOrgV1BGPConfigurationSpecServiceExternalIPsItems0:
"""
ServiceExternalIPBlock represents a single allowed External IP CIDR block.

Attributes
----------
cidr : str, default is Undefined, optional
cidr
"""


cidr?: str


schema CrdProjectcalicoOrgV1BGPConfigurationSpecServiceLoadBalancerIPsItems0:
"""
ServiceLoadBalancerIPBlock represents a single allowed LoadBalancer IP CIDR block.

Attributes
----------
cidr : str, default is Undefined, optional
cidr
"""


cidr?: str


119 changes: 119 additions & 0 deletions cluster-api-provider-vsphere/v1/crd_projectcalico_org_v1_b_g_p_peer.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
"""
import k8s.apimachinery.pkg.apis.meta.v1


schema BGPPeer:
"""
crd projectcalico org v1 b g p peer

Attributes
----------
apiVersion : str, default is "crd.projectcalico.org/v1", required
APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind : str, default is "BGPPeer", required
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata : v1.ObjectMeta, default is Undefined, optional
metadata
spec : CrdProjectcalicoOrgV1BGPPeerSpec, default is Undefined, optional
spec
"""


apiVersion: "crd.projectcalico.org/v1" = "crd.projectcalico.org/v1"

kind: "BGPPeer" = "BGPPeer"

metadata?: v1.ObjectMeta

spec?: CrdProjectcalicoOrgV1BGPPeerSpec


schema CrdProjectcalicoOrgV1BGPPeerSpec:
"""
BGPPeerSpec contains the specification for a BGPPeer resource.

Attributes
----------
asNumber : int, default is Undefined, optional
The AS Number of the peer.
keepOriginalNextHop : bool, default is Undefined, optional
Option to keep the original nexthop field when routes are sent to a BGP Peer. Setting "true" configures the selected BGP Peers node to use the "next hop keep;" instead of "next hop self;"(default) in the specific branch of the Node on "bird.cfg".
maxRestartTime : str, default is Undefined, optional
Time to allow for software restart. When specified, this is configured as the graceful restart timeout. When not specified, the BIRD default of 120s is used.
node : str, default is Undefined, optional
The node name identifying the Calico node instance that is targeted by this peer. If this is not set, and no nodeSelector is specified, then this BGP peer selects all nodes in the cluster.
nodeSelector : str, default is Undefined, optional
Selector for the nodes that should have this peering. When this is set, the Node field must be empty.
numAllowedLocalASNumbers : int, default is Undefined, optional
Maximum number of local AS numbers that are allowed in the AS path for received routes. This removes BGP loop prevention and should only be used if absolutely necesssary.
password : CrdProjectcalicoOrgV1BGPPeerSpecPassword, default is Undefined, optional
password
peerIP : str, default is Undefined, optional
The IP address of the peer followed by an optional port number to peer with. If port number is given, format should be `[<IPv6>]:port` or `<IPv4>:<port>` for IPv4. If optional port number is not set, and this peer IP and ASNumber belongs to a calico/node with ListenPort set in BGPConfiguration, then we use that port to peer.
peerSelector : str, default is Undefined, optional
Selector for the remote nodes to peer with. When this is set, the PeerIP and ASNumber fields must be empty. For each peering between the local node and selected remote nodes, we configure an IPv4 peering if both ends have NodeBGPSpec.IPv4Address specified, and an IPv6 peering if both ends have NodeBGPSpec.IPv6Address specified. The remote AS number comes from the remote node's NodeBGPSpec.ASNumber, or the global default if that is not set.
sourceAddress : str, default is Undefined, optional
Specifies whether and how to configure a source address for the peerings generated by this BGPPeer resource. Default value "UseNodeIP" means to configure the node IP as the source address. "None" means not to configure a source address.
"""


asNumber?: int

keepOriginalNextHop?: bool

maxRestartTime?: str

node?: str

nodeSelector?: str

numAllowedLocalASNumbers?: int

password?: CrdProjectcalicoOrgV1BGPPeerSpecPassword

peerIP?: str

peerSelector?: str

sourceAddress?: str


schema CrdProjectcalicoOrgV1BGPPeerSpecPassword:
"""
Optional BGP password for the peerings generated by this BGPPeer resource.

Attributes
----------
secretKeyRef : CrdProjectcalicoOrgV1BGPPeerSpecPasswordSecretKeyRef, default is Undefined, optional
secret key ref
"""


secretKeyRef?: CrdProjectcalicoOrgV1BGPPeerSpecPasswordSecretKeyRef


schema CrdProjectcalicoOrgV1BGPPeerSpecPasswordSecretKeyRef:
"""
Selects a key of a secret in the node pod's namespace.

Attributes
----------
key : str, default is Undefined, required
The key of the secret to select from. Must be a valid secret key.
name : str, default is Undefined, optional
Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?
optional : bool, default is Undefined, optional
Specify whether the Secret or its key must be defined
"""


key: str

name?: str

optional?: bool


Loading

0 comments on commit 539fdad

Please sign in to comment.