Skip to content

Commit

Permalink
Quick fixes for e2e testing
Browse files Browse the repository at this point in the history
  • Loading branch information
joekr committed Apr 21, 2022
1 parent 5c4c05d commit c231467
Show file tree
Hide file tree
Showing 8 changed files with 2,201 additions and 75 deletions.
5 changes: 0 additions & 5 deletions api/v1beta1/ocicluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,9 @@ var clusterlogger = ctrl.Log.WithName("ocicluster-resource")

var (
_ webhook.Validator = &OCICluster{}
_ webhook.Defaulter = &OCICluster{}
)

// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-ocicluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ociclusters,versions=v1beta1,name=validation.ocicluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-ocicluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ociclusters,versions=v1beta1,name=default.ocicluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1

// Default implements webhook.Defaulter so a webhook will be registered for the type.
func (c *OCICluster) Default() {}

func (c *OCICluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
clusterlogger.Info("validate create cluster", "name", c.Name)
Expand Down
8 changes: 2 additions & 6 deletions api/v1beta1/ocimachinetemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ import (

var (
_ webhook.Validator = &OCIMachineTemplate{}
_ webhook.Defaulter = &OCIMachineTemplate{}
//_ webhook.Defaulter = &OCIMachineTemplate{}
)

// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-ocimachinetemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ocimachinetemplates,versions=v1beta1,name=validation.ocimachinetemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-ocimachinetemplate,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ocimachinetemplates,versions=v1beta1,name=default.ocimachinetemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1

// Default implements webhook.Defaulter so a webhook will be registered for the type.
func (m *OCIMachineTemplate) Default() {}

func (m *OCIMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
Expand Down Expand Up @@ -84,7 +80,7 @@ func (m *OCIMachineTemplate) ValidateUpdate(old runtime.Object) error {
func (m *OCIMachineTemplate) validate() field.ErrorList {
var allErrs field.ErrorList

if !validOcid(m.Spec.Template.Spec.ImageId) {
if len(m.Spec.Template.Spec.ImageId) > 0 && !validOcid(m.Spec.Template.Spec.ImageId) {
allErrs = append(
allErrs,
field.Invalid(
Expand Down
16 changes: 9 additions & 7 deletions config/default/webhookcainjection_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# This patch add annotation to admission webhook config and
# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: mutating-webhook-configuration
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
---

# TODO: uncomment as part of https://github.com/oracle/cluster-api-provider-oci/issues/56
#apiVersion: admissionregistration.k8s.io/v1
#kind: MutatingWebhookConfiguration
#metadata:
# name: mutating-webhook-configuration
# annotations:
# cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
#---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
Expand Down
16 changes: 9 additions & 7 deletions config/webhook/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ nameReference:
- kind: Service
version: v1
fieldSpecs:
- kind: MutatingWebhookConfiguration
group: admissionregistration.k8s.io
path: webhooks/clientConfig/service/name
# TODO: uncomment as part of https://github.com/oracle/cluster-api-provider-oci/issues/56
# - kind: MutatingWebhookConfiguration
# group: admissionregistration.k8s.io
# path: webhooks/clientConfig/service/name
- kind: ValidatingWebhookConfiguration
group: admissionregistration.k8s.io
path: webhooks/clientConfig/service/name

namespace:
- kind: MutatingWebhookConfiguration
group: admissionregistration.k8s.io
path: webhooks/clientConfig/service/namespace
create: true
# TODO: uncomment as part of https://github.com/oracle/cluster-api-provider-oci/issues/56
# - kind: MutatingWebhookConfiguration
# group: admissionregistration.k8s.io
# path: webhooks/clientConfig/service/namespace
# create: true
- kind: ValidatingWebhookConfiguration
group: admissionregistration.k8s.io
path: webhooks/clientConfig/service/namespace
Expand Down
50 changes: 0 additions & 50 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,54 +1,4 @@

---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- admissionReviewVersions:
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-infrastructure-cluster-x-k8s-io-v1beta1-ocicluster
failurePolicy: Fail
matchPolicy: Equivalent
name: default.ocicluster.infrastructure.cluster.x-k8s.io
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- ociclusters
sideEffects: None
- admissionReviewVersions:
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-infrastructure-cluster-x-k8s-io-v1beta1-ocimachinetemplate
failurePolicy: Fail
matchPolicy: Equivalent
name: default.ocimachinetemplate.infrastructure.cluster.x-k8s.io
rules:
- apiGroups:
- infrastructure.cluster.x-k8s.io
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- ocimachinetemplates
sideEffects: None

---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
labels:
cni: ${CLUSTER_NAME}-0
name: ${CLUSTER_NAME}
spec:
clusterNetwork:
pods:
cidrBlocks:
- 192.168.0.0/16
topology:
class: test-cluster-class
controlPlane:
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
variables:
- name: ssh_authorized_keys
value: ${OCI_SSH_KEY}
- name: compartmentId
value: ${OCI_COMPARTMENT_ID}
- name: imageId
value: ${OCI_IMAGE_ID}
version: ${KUBERNETES_VERSION}
workers:
machineDeployments:
- class: worker
name: md-0
replicas: ${WORKER_MACHINE_COUNT}
Loading

0 comments on commit c231467

Please sign in to comment.