Skip to content

Commit

Permalink
now webhooks are working
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakm-ntnx committed Dec 7, 2023
1 parent a71c968 commit bf36a35
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 12 deletions.
4 changes: 2 additions & 2 deletions api/infrastructure/v1beta1/nutanixcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *NutanixCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclusters,verbs=create;update,versions=v1beta1,name=mnutanixcluster.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixcluster,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclusters,verbs=create;update,versions=v1beta1,name=mnutanixcluster.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Defaulter = &NutanixCluster{}

Expand All @@ -48,7 +48,7 @@ func (r *NutanixCluster) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclusters,verbs=create;update,versions=v1beta1,name=vnutanixcluster.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclusters,verbs=create;update,versions=v1beta1,name=vnutanixcluster.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Validator = &NutanixCluster{}

Expand Down
4 changes: 2 additions & 2 deletions api/infrastructure/v1beta1/nutanixclustertemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *NutanixClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixclustertemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclustertemplates,verbs=create;update,versions=v1beta1,name=mnutanixclustertemplate.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixclustertemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclustertemplates,verbs=create;update,versions=v1beta1,name=mnutanixclustertemplate.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Defaulter = &NutanixClusterTemplate{}

Expand All @@ -48,7 +48,7 @@ func (r *NutanixClusterTemplate) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixclustertemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclustertemplates,verbs=create;update,versions=v1beta1,name=vnutanixclustertemplate.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixclustertemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixclustertemplates,verbs=create;update,versions=v1beta1,name=vnutanixclustertemplate.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Validator = &NutanixClusterTemplate{}

Expand Down
4 changes: 2 additions & 2 deletions api/infrastructure/v1beta1/nutanixmachinetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (r *NutanixMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error

// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!

//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixmachinetemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixmachinetemplates,verbs=create;update,versions=v1beta1,name=mnutanixmachinetemplate.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixmachinetemplate,mutating=true,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixmachinetemplates,verbs=create;update,versions=v1beta1,name=mnutanixmachinetemplate.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Defaulter = &NutanixMachineTemplate{}

Expand All @@ -48,7 +48,7 @@ func (r *NutanixMachineTemplate) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixmachinetemplates,verbs=create;update,versions=v1beta1,name=vnutanixmachinetemplate.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-nutanixmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=nutanixmachinetemplates,verbs=create;update,versions=v1beta1,name=vnutanixmachinetemplate.kb.io,admissionReviewVersions=v1beta1

var _ webhook.Validator = &NutanixMachineTemplate{}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,98 @@ spec:
- host
- port
type: object
failureDomains:
description: failureDomains configures failure domains information
for the Nutanix platform. When set, the failure domains
defined here may be used to spread Machines across prism
element clusters to improve fault tolerance of the cluster.
items:
description: NutanixFailureDomain configures failure domain
information for Nutanix.
properties:
cluster:
description: cluster is to identify the cluster (the
Prism Element under management of the Prism Central),
in which the Machine's VM will be created. The cluster
identifier (uuid or name) can be obtained from the
Prism Central console or using the prism_central API.
properties:
name:
description: name is the resource name in the PC
type: string
type:
description: Type is the identifier type to use
for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource in
the PC.
type: string
required:
- type
type: object
controlPlane:
description: indicates if a failure domain is suited
for control plane nodes
type: boolean
name:
description: name defines the unique name of a failure
domain. Name is required and must be at most 64 characters
in length. It must consist of only lower case alphanumeric
characters and hyphens (-). It must start and end
with an alphanumeric character. This value is arbitrary
and is used to identify the failure domain within
the platform.
maxLength: 64
minLength: 1
pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?'
type: string
subnets:
description: subnets holds a list of identifiers (one
or more) of the cluster's network subnets for the
Machine's VM to connect to. The subnet identifiers
(uuid or name) can be obtained from the Prism Central
console or using the prism_central API.
items:
description: NutanixResourceIdentifier holds the identity
of a Nutanix PC resource (cluster, image, subnet,
etc.)
properties:
name:
description: name is the resource name in the
PC
type: string
type:
description: Type is the identifier type to use
for this resource.
enum:
- uuid
- name
type: string
uuid:
description: uuid is the UUID of the resource
in the PC.
type: string
required:
- type
type: object
minItems: 1
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
required:
- cluster
- name
- subnets
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
prismCentral:
description: prismCentral holds the endpoint address and port
to access the Nutanix Prism Central. When a cluster-wide
Expand Down
12 changes: 6 additions & 6 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand All @@ -25,7 +25,7 @@ webhooks:
- nutanixclusters
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand All @@ -45,7 +45,7 @@ webhooks:
- nutanixclustertemplates
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand All @@ -71,7 +71,7 @@ metadata:
name: validating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand All @@ -91,7 +91,7 @@ webhooks:
- nutanixclusters
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand All @@ -111,7 +111,7 @@ webhooks:
- nutanixclustertemplates
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
Expand Down
1 change: 1 addition & 0 deletions templates/base/cluster-with-kcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: "${CLUSTER_NAME}"
namespace: "${NAMESPACE}"
spec:
failureDomains: []
prismCentral:
address: "${NUTANIX_ENDPOINT}"
port: ${NUTANIX_PORT=9440}
Expand Down

0 comments on commit bf36a35

Please sign in to comment.