From 12ed7340cfc5311e3f1a65f64df1c6e3305663f3 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Wed, 15 May 2024 18:03:47 +0200 Subject: [PATCH] removed unused leftovers --- Makefile | 3 - config/gateway-api/gateway/gateway.yaml | 19 --- config/gateway-api/gateway/kustomization.yaml | 5 - make/gateway-api.mk | 4 - make/istio.mk | 25 --- make/olm.mk | 5 - pkg/utils/k8s_utils.go | 147 ------------------ utils/istio-operator.yaml | 53 ------- 8 files changed, 261 deletions(-) delete mode 100644 config/gateway-api/gateway/gateway.yaml delete mode 100644 config/gateway-api/gateway/kustomization.yaml delete mode 100644 make/istio.mk delete mode 100644 make/olm.mk delete mode 100644 pkg/utils/k8s_utils.go delete mode 100644 utils/istio-operator.yaml diff --git a/Makefile b/Makefile index f860058..e84e607 100644 --- a/Makefile +++ b/Makefile @@ -63,10 +63,7 @@ prepare-local-cluster: $(KIND) ## Deploy locally kuadrant operator from the curr .PHONY: env-setup env-setup: - $(MAKE) olm-install $(MAKE) gateway-api-install - $(MAKE) istio-install - $(MAKE) deploy-gateway ## local-setup: Sets up Kind cluster with GatewayAPI manifests and istio GW, nothing Kuadrant. Build and install kuadrantctl binary .PHONY: local-setup diff --git a/config/gateway-api/gateway/gateway.yaml b/config/gateway-api/gateway/gateway.yaml deleted file mode 100644 index 7886c7a..0000000 --- a/config/gateway-api/gateway/gateway.yaml +++ /dev/null @@ -1,19 +0,0 @@ ---- -apiVersion: gateway.networking.k8s.io/v1beta1 -kind: Gateway -metadata: - labels: - istio: ingressgateway - name: istio-ingressgateway -spec: - gatewayClassName: istio - listeners: - - name: default - port: 80 - protocol: HTTP - allowedRoutes: - namespaces: - from: All - addresses: - - value: istio-ingressgateway.istio-system.svc.cluster.local - type: Hostname diff --git a/config/gateway-api/gateway/kustomization.yaml b/config/gateway-api/gateway/kustomization.yaml deleted file mode 100644 index b489ae5..0000000 --- a/config/gateway-api/gateway/kustomization.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -# Adds namespace to all resources. -namespace: istio-system -resources: -- gateway.yaml diff --git a/make/gateway-api.mk b/make/gateway-api.mk index e96f660..81bd84e 100644 --- a/make/gateway-api.mk +++ b/make/gateway-api.mk @@ -1,9 +1,5 @@ ##@ Gateway API resources -.PHONY: deploy-gateway -deploy-gateway: kustomize ## Deploy Gateway API gateway - $(KUSTOMIZE) build config/gateway-api/gateway | kubectl apply -f - - .PHONY: gateway-api-install gateway-api-install: kustomize ## Install Gateway API CRDs $(KUSTOMIZE) build config/gateway-api | kubectl apply -f - diff --git a/make/istio.mk b/make/istio.mk deleted file mode 100644 index a958dd9..0000000 --- a/make/istio.mk +++ /dev/null @@ -1,25 +0,0 @@ - -##@ Istio - -## Targets to help install and configure istio - -# istioctl tool -ISTIOCTL=$(shell pwd)/bin/istioctl -ISTIOVERSION = 1.19.3 -$(ISTIOCTL): - mkdir -p $(shell pwd)/bin - $(eval TMP := $(shell mktemp -d)) - cd $(TMP); curl -sSL https://istio.io/downloadIstio | ISTIO_VERSION=$(ISTIOVERSION) sh - - cp $(TMP)/istio-$(ISTIOVERSION)/bin/istioctl ${ISTIOCTL} - -rm -rf $(TMP) - -.PHONY: istioctl -istioctl: $(ISTIOCTL) ## Download istioctl locally if necessary. - -.PHONY: istio-install -istio-install: istioctl ## Install istio. - $(ISTIOCTL) install -f utils/istio-operator.yaml -y - -.PHONY: istio-uninstall -istio-uninstall: istioctl ## Uninstall istio. - $(ISTIOCTL) uninstall -y --purge diff --git a/make/olm.mk b/make/olm.mk deleted file mode 100644 index 59e5e27..0000000 --- a/make/olm.mk +++ /dev/null @@ -1,5 +0,0 @@ -##@ Install Operator Lifecycle Manager (OLM), a tool to help manage the Operators running on your cluster. - -.PHONY: olm-install -olm-install: - curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.26.0/install.sh | bash -s v0.26.0 diff --git a/pkg/utils/k8s_utils.go b/pkg/utils/k8s_utils.go deleted file mode 100644 index 80e87d6..0000000 --- a/pkg/utils/k8s_utils.go +++ /dev/null @@ -1,147 +0,0 @@ -/* -Copyright 2021 Red Hat, Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ -package utils - -import ( - "context" - "errors" - - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/meta" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" - "sigs.k8s.io/controller-runtime/pkg/client" - logf "sigs.k8s.io/controller-runtime/pkg/log" -) - -func CreateOrUpdateK8SObject(k8sClient client.Client, obj runtime.Object) error { - k8sObj, ok := obj.(client.Object) - if !ok { - return errors.New("runtime.Object could not be casted to client.Object") - } - - err := k8sClient.Create(context.Background(), k8sObj) - logf.Log.V(1).Info("create resource", "GKV", k8sObj.GetObjectKind().GroupVersionKind(), "name", k8sObj.GetName(), "error", err) - if err == nil { - return nil - } - - if !apierrors.IsAlreadyExists(err) { - return err - } - - // Already exists - currentObj := k8sObj.DeepCopyObject() - k8sCurrentObj, ok := currentObj.(client.Object) - if !ok { - return errors.New("runtime.Object could not be casted to client.Object") - } - err = k8sClient.Get(context.Background(), client.ObjectKeyFromObject(k8sObj), k8sCurrentObj) - if err != nil { - return err - } - - objCopy := k8sObj.DeepCopyObject() - - objCopyMetadata, err := meta.Accessor(objCopy) - if err != nil { - return err - } - - objCopyMetadata.SetResourceVersion(k8sCurrentObj.GetResourceVersion()) - - k8sObjCopy, ok := objCopy.(client.Object) - if !ok { - return errors.New("runtime.Object could not be casted to client.Object") - } - - err = k8sClient.Update(context.Background(), k8sObjCopy) - logf.Log.Info("update resource", "GKV", k8sObj.GetObjectKind().GroupVersionKind(), "name", k8sObj.GetName(), "error", err) - return err -} - -func CreateOnlyK8SObject(k8sClient client.Client, obj runtime.Object) error { - k8sObj, ok := obj.(client.Object) - if !ok { - return errors.New("runtime.Object could not be casted to client.Object") - } - k8sObjKind := k8sObj.DeepCopyObject().GetObjectKind() - - err := k8sClient.Create(context.Background(), k8sObj) - logf.Log.V(1).Info("create resource", "GKV", k8sObjKind.GroupVersionKind(), "name", k8sObj.GetName(), "error", err) - if err != nil { - if apierrors.IsAlreadyExists(err) { - // Omit error - logf.Log.Info("Already exists", "GKV", k8sObjKind.GroupVersionKind(), "name", k8sObj.GetName()) - } else { - return err - } - } - return nil -} - -func DeleteK8SObject(k8sClient client.Client, obj runtime.Object) error { - k8sObj, ok := obj.(client.Object) - if !ok { - return errors.New("runtime.Object could not be casted to client.Object") - } - k8sObjKind := k8sObj.DeepCopyObject().GetObjectKind() - - err := k8sClient.Delete(context.Background(), k8sObj) - logf.Log.V(1).Info("delete resource", "GKV", k8sObjKind.GroupVersionKind(), "name", k8sObj.GetName(), "error", err) - if err != nil && !apierrors.IsNotFound(err) { - // Omit NotFound error - return err - } - return nil -} - -// IsDeploymentAvailable returns true when the provided Deployment -// has the "Available" condition set to true -func IsDeploymentAvailable(dc *appsv1.Deployment) bool { - dcConditions := dc.Status.Conditions - for _, dcCondition := range dcConditions { - if dcCondition.Type == appsv1.DeploymentAvailable && dcCondition.Status == corev1.ConditionTrue { - return true - } - } - return false -} - -func CheckDeploymentAvailable(ctx context.Context, k8sClient client.Client, key types.NamespacedName) (bool, error) { - existingDeployment := &appsv1.Deployment{} - err := k8sClient.Get(ctx, key, existingDeployment) - if err != nil { - if apierrors.IsNotFound(err) { - logf.Log.Info("Deployment not available", "name", key.Name) - return false, nil - } - - return false, err - } - - if !IsDeploymentAvailable(existingDeployment) { - logf.Log.Info("Waiting for full availability", "Deployment", existingDeployment.GetName(), - "available replicas", existingDeployment.Status.AvailableReplicas, "desired replics", - *existingDeployment.Spec.Replicas) - return false, nil - } - - logf.Log.Info("Deployment available", "name", existingDeployment.GetName()) - return true, nil -} diff --git a/utils/istio-operator.yaml b/utils/istio-operator.yaml deleted file mode 100644 index 05db21c..0000000 --- a/utils/istio-operator.yaml +++ /dev/null @@ -1,53 +0,0 @@ ---- -apiVersion: install.istio.io/v1alpha1 -kind: IstioOperator -spec: - profile: default - namespace: istio-system - components: - base: - enabled: true - cni: - enabled: false - egressGateways: - - enabled: false - name: istio-egressgateway - ingressGateways: - - enabled: true - name: istio-ingressgateway - k8s: - service: - type: NodePort - ports: - - name: status-port - port: 15021 - protocol: TCP - targetPort: 15021 - - name: http2 - port: 80 - protocol: TCP - targetPort: 8080 - nodePort: 30950 - - name: https - port: 443 - protocol: TCP - targetPort: 8443 - nodePort: 30951 - resources: - requests: - cpu: "0" - pilot: - enabled: true - k8s: - resources: - requests: - cpu: "0" - values: - pilot: - autoscaleEnabled: false - gateways: - istio-ingressgateway: - type: ClusterIP - autoscaleEnabled: false - global: - istioNamespace: istio-system