Skip to content

Commit

Permalink
chore: replace deprecated APIs and update dependencies to support Kub…
Browse files Browse the repository at this point in the history
…ernetes 1.23

 - change apiextensions.k8s.io/v1beta1 to apiextensions.k8s.io/v1
 - change admissionregistration.k8s.io/v1beta1 to admissionregistration.k8s.io/v1
 - change k8s.io/api/admission/v1beta1 to k8s.io/api/admission/v1
 - update sigs.k8s.io/controller-tools/cmd/controller-gen to 0.4.1
 - update sigs.k8s.io/kustomize/kustomize to 3.8.3
 - remove webhook generation part for contoller-gen
   (without this "caBundle" was removing from webhook specification)
 - add sideEffects=none,admissionReviewVersions=v1 to annotation for kubebuilder
   which is used to generate webhook template
 - update sigs.k8s.io/controller-runtime to v0.8.3
 - update k8s.io/apimachinery to v0.20.2
 - update k8s.io/client-go to v0.20.2
 - update k8s.io/api to v0.20.2
 - update gomodules.xyz/jsonpatch/v2 to 2.1.0
 - update github.com/go-logr/logr v0.3.0
 - adjust code to updated dependecies
 - change Kuberentes version in Vagrant environment to 1.23
 - change Cert Manager version in Vagrant environment to v1.5.0
  • Loading branch information
kasia-kujawa committed Jul 29, 2022
1 parent a870f1c commit 3e3ff8e
Show file tree
Hide file tree
Showing 18 changed files with 486 additions and 112 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{{- define "tailing-sidecar-operator.webhookWithCertManager" }}
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
annotations:
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/tailing-sidecar-serving-cert
name: tailing-sidecar-mutating-webhook-configuration
namespace: {{ .Release.Namespace }}
webhooks:
- clientConfig:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
caBundle: Cg==
service:
name: {{ include "tailing-sidecar-operator.fullname" . }}
Expand All @@ -30,6 +33,7 @@ webhooks:
- UPDATE
resources:
- pods
sideEffects: None
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
Expand Down
8 changes: 6 additions & 2 deletions helm/tailing-sidecar-operator/templates/_operator-webhook.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
{{- $altNames := list ( printf "%s.%s" (include "tailing-sidecar-operator.fullname" .) .Release.Namespace ) ( printf "%s.%s.svc" (include "tailing-sidecar-operator.fullname" .) .Release.Namespace ) -}}
{{- $ca := genCA "tailing-sidecar-operator-ca" 365 -}}
{{- $cert := genSignedCert ( include "tailing-sidecar-operator.fullname" . ) nil $altNames 365 $ca -}}
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: tailing-sidecar-mutating-webhook-configuration
namespace: {{ .Release.Namespace }}
webhooks:
- clientConfig:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
caBundle: {{ $ca.Cert | b64enc }}
service:
name: {{ include "tailing-sidecar-operator.fullname" . }}
Expand All @@ -31,6 +34,7 @@ webhooks:
- UPDATE
resources:
- pods
sideEffects: None
---
apiVersion: v1
kind: Secret
Expand Down
81 changes: 39 additions & 42 deletions helm/tailing-sidecar-operator/templates/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: tailingsidecars.tailing-sidecar.sumologic.com
spec:
Expand All @@ -13,48 +13,45 @@ spec:
plural: tailingsidecars
singular: tailingsidecar
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: TailingSidecar is the Schema for the tailingsidecars API
properties:
apiVersion:
description: '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'
type: string
kind:
description: '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'
type: string
metadata:
type: object
spec:
description: TailingSidecarSpec defines the desired state of TailingSidecar
properties:
configs:
additionalProperties:
properties:
container:
type: string
file:
type: string
volume:
type: string
type: object
description: Configs contains configurations for tailing sidecars, map
key indicates name of configuration which can be used in annotation
type: object
type: object
status:
description: TailingSidecarStatus defines the observed state of TailingSidecar
type: object
type: object
version: v1
versions:
- name: v1
schema:
openAPIV3Schema:
description: TailingSidecar is the Schema for the tailingsidecars API
properties:
apiVersion:
description: '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'
type: string
kind:
description: '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'
type: string
metadata:
type: object
spec:
description: TailingSidecarSpec defines the desired state of TailingSidecar
properties:
configs:
additionalProperties:
properties:
container:
type: string
file:
type: string
volume:
type: string
type: object
description: Configs contains configurations for tailing sidecars,
map key indicates name of configuration which can be used in annotation
type: object
type: object
status:
description: TailingSidecarStatus defines the observed state of TailingSidecar
type: object
type: object
served: true
storage: true
---
Expand Down
8 changes: 4 additions & 4 deletions operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ IMG ?= localhost:32000/sumologic/tailing-sidecar-operator:latest
TAILING_SIDECAR_IMG ?= localhost:32000/sumologic/tailing-sidecar:latest

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"
CRD_OPTIONS ?= "crd:crdVersions={v1},trivialVersions=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -147,7 +147,7 @@ deploy-cert-manager:

# Generate manifests e.g. CRD, RBAC etc.
manifests: controller-gen
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases

# Run go fmt against code
fmt:
Expand Down Expand Up @@ -182,7 +182,7 @@ ifeq (, $(shell which controller-gen))
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand All @@ -197,7 +197,7 @@ ifeq (, $(shell which kustomize))
KUSTOMIZE_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$KUSTOMIZE_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4 ;\
go get sigs.k8s.io/kustomize/kustomize/v3@v3.8.3 ;\
rm -rf $$KUSTOMIZE_GEN_TMP_DIR ;\
}
KUSTOMIZE=$(GOBIN)/kustomize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.3.0
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: tailingsidecars.tailing-sidecar.sumologic.com
spec:
Expand All @@ -15,50 +15,49 @@ spec:
plural: tailingsidecars
singular: tailingsidecar
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: TailingSidecar is the Schema for the tailingsidecars API
properties:
apiVersion:
description: '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'
type: string
kind:
description: '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'
type: string
metadata:
type: object
spec:
description: TailingSidecarSpec defines the desired state of TailingSidecar
properties:
configs:
additionalProperties:
properties:
container:
type: string
file:
type: string
volume:
type: string
type: object
description: Configs contains configurations for tailing sidecars, map
key indicates name of configuration which can be used in annotation
type: object
type: object
status:
description: TailingSidecarStatus defines the observed state of TailingSidecar
type: object
type: object
version: v1
versions:
- name: v1
schema:
openAPIV3Schema:
description: TailingSidecar is the Schema for the tailingsidecars API
properties:
apiVersion:
description: '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'
type: string
kind:
description: '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'
type: string
metadata:
type: object
spec:
description: TailingSidecarSpec defines the desired state of TailingSidecar
properties:
configs:
additionalProperties:
properties:
container:
type: string
file:
type: string
volume:
type: string
type: object
description: Configs contains configurations for tailing sidecars,
map key indicates name of configuration which can be used in annotation
type: object
type: object
status:
description: TailingSidecarStatus defines the observed state of TailingSidecar
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The following patch enables conversion webhook for CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: tailingsidecars.tailing-sidecar.sumologic.com
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This patch adds annotation to admission webhook config and
# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: mutating-webhook-configuration
Expand Down
2 changes: 1 addition & 1 deletion operator/config/default/webhook_patch.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: mutating-webhook-configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This patch adds annotation to admission webhook config and
# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: validating-webhook-configuration
Expand Down
9 changes: 7 additions & 2 deletions operator/config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@

---
apiVersion: admissionregistration.k8s.io/v1beta1
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
creationTimestamp: null
name: mutating-webhook-configuration
webhooks:
- clientConfig:
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
caBundle: Cg==
service:
name: webhook-service
Expand All @@ -22,5 +25,7 @@ webhooks:
operations:
- CREATE
- UPDATE
- DELETE
resources:
- pods
sideEffects: None
2 changes: 1 addition & 1 deletion operator/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestAPIs(t *testing.T) {
}

var _ = BeforeSuite(func(done Done) {
logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))

By("bootstrapping test environment")
testEnv = &envtest.Environment{
Expand Down
2 changes: 1 addition & 1 deletion operator/controllers/tailingsidecar_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type TailingSidecarReconciler struct {
// +kubebuilder:rbac:groups=tailing-sidecar.sumologic.com,resources=tailingsidecars,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=tailing-sidecar.sumologic.com,resources=tailingsidecars/status,verbs=get;update;patch

func (r *TailingSidecarReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
func (r *TailingSidecarReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
_ = context.Background()
_ = r.Log.WithValues("tailingsidecar", req.NamespacedName)

Expand Down
12 changes: 6 additions & 6 deletions operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ module github.com/SumoLogic/tailing-sidecar/operator
go 1.13

require (
github.com/go-logr/logr v0.1.0
github.com/go-logr/logr v0.3.0
github.com/google/uuid v1.2.0
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce
github.com/onsi/ginkgo v1.15.1
github.com/onsi/gomega v1.11.0
gomodules.xyz/jsonpatch/v2 v2.0.1
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
k8s.io/client-go v0.18.6
sigs.k8s.io/controller-runtime v0.6.4
gomodules.xyz/jsonpatch/v2 v2.1.0
k8s.io/api v0.20.2
k8s.io/apimachinery v0.20.2
k8s.io/client-go v0.20.2
sigs.k8s.io/controller-runtime v0.8.3
)
Loading

0 comments on commit 3e3ff8e

Please sign in to comment.