From: naman.gupta Date: Fri, 1 Dec 2023 18:27:53 +0000 (+0530) Subject: Adding CustomResourceDefinition Job and StatefulSet. X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=59a3ef9a08ffbaa63e61a7ab1f4466c148846a00;p=ric-plt%2Fric-dep.git Adding CustomResourceDefinition Job and StatefulSet. Adding CustomResourceDefinition, Job, EndPoints and StatefulSet. Change-Id: I1ed0711e4684cea9ceceee372857deddfcae9dee Signed-off-by: naman.gupta --- diff --git a/depRicKubernetesOperator/internal/controller/getCustomResourceDefinition.go b/depRicKubernetesOperator/internal/controller/getCustomResourceDefinition.go new file mode 100644 index 0000000..cde8a44 --- /dev/null +++ b/depRicKubernetesOperator/internal/controller/getCustomResourceDefinition.go @@ -0,0 +1,989 @@ +package controller + +import ( + "context" + "fmt" +) + +func GetCustomResourceDefinition() []*unstructured.Unstructured { + + customResourceDefinition1 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + }, + "name": "kongconsumers.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "kind": "KongConsumer", + "plural": "kongconsumers", + "shortNames": []interface{}{ + "kc", + }, + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "credentials": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + }, + "type": "array", + }, + "custom_id": map[string]interface{}{ + "type": "string", + }, + "username": map[string]interface{}{ + "type": "string", + }, + }, + }, + }, + "version": "v1", + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "JSONPath": ".username", + "description": "Username of a Kong Consumer", + "name": "Username", + "type": "string", + }, + map[string]interface{}{ + "type": "date", + "JSONPath": ".metadata.creationTimestamp", + "description": "Age", + "name": "Age", + }, + }, + }, + }, + } + + customResourceDefinition2 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + }, + "name": "kongcredentials.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "version": "v1", + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "JSONPath": ".type", + "description": "Type of credential", + "name": "Credential-type", + "type": "string", + }, + map[string]interface{}{ + "JSONPath": ".metadata.creationTimestamp", + "description": "Age", + "name": "Age", + "type": "date", + }, + map[string]interface{}{ + "type": "string", + "JSONPath": ".consumerRef", + "description": "Owner of the credential", + "name": "Consumer-Ref", + }, + }, + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "kind": "KongCredential", + "plural": "kongcredentials", + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "consumerRef": map[string]interface{}{ + "type": "string", + }, + "type": map[string]interface{}{ + "type": "string", + }, + }, + "required": []interface{}{ + "consumerRef", + "type", + }, + }, + }, + }, + }, + } + + customResourceDefinition3 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "spec": map[string]interface{}{ + "names": map[string]interface{}{ + "kind": "KongPlugin", + "plural": "kongplugins", + "shortNames": []interface{}{ + "kp", + }, + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "protocols": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + "enum": []interface{}{ + "http", + "https", + "tcp", + "tls", + "grpc", + "grpcs", + }, + }, + "type": "array", + }, + "run_on": map[string]interface{}{ + "enum": []interface{}{ + "first", + "second", + "all", + }, + "type": "string", + }, + "config": map[string]interface{}{ + "type": "object", + }, + "disabled": map[string]interface{}{ + "type": "boolean", + }, + "plugin": map[string]interface{}{ + "type": "string", + }, + }, + "required": []interface{}{ + "plugin", + }, + }, + }, + "version": "v1", + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "JSONPath": ".plugin", + "description": "Name of the plugin", + "name": "Plugin-Type", + "type": "string", + }, + map[string]interface{}{ + "description": "Age", + "name": "Age", + "type": "date", + "JSONPath": ".metadata.creationTimestamp", + }, + map[string]interface{}{ + "JSONPath": ".disabled", + "description": "Indicates if the plugin is disabled", + "name": "Disabled", + "priority": 1, + "type": "boolean", + }, + map[string]interface{}{ + "JSONPath": ".config", + "description": "Configuration of the plugin", + "name": "Config", + "priority": 1, + "type": "string", + }, + }, + "group": "configuration.konghq.com", + }, + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + }, + "name": "kongplugins.configuration.konghq.com", + }, + }, + } + + customResourceDefinition4 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "spec": map[string]interface{}{ + "version": "v1", + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "plural": "kongingresses", + "shortNames": []interface{}{ + "ki", + }, + "kind": "KongIngress", + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "upstream": map[string]interface{}{ + "properties": map[string]interface{}{ + "hash_fallback_header": map[string]interface{}{ + "type": "string", + }, + "hash_on": map[string]interface{}{ + "type": "string", + }, + "hash_on_cookie": map[string]interface{}{ + "type": "string", + }, + "hash_on_cookie_path": map[string]interface{}{ + "type": "string", + }, + "healthchecks": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "passive": map[string]interface{}{ + "properties": map[string]interface{}{ + "healthy": map[string]interface{}{ + "properties": map[string]interface{}{ + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "successes": map[string]interface{}{ + "type": "integer", + "minimum": 0, + }, + }, + "type": "object", + }, + "unhealthy": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "http_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "tcp_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + }, + }, + "type": "object", + }, + "active": map[string]interface{}{ + "properties": map[string]interface{}{ + "concurrency": map[string]interface{}{ + "minimum": 1, + "type": "integer", + }, + "healthy": map[string]interface{}{ + "properties": map[string]interface{}{ + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "successes": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + "type": "object", + }, + "http_path": map[string]interface{}{ + "pattern": "^/.*$", + "type": "string", + }, + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "unhealthy": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "http_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "tcp_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + }, + }, + "type": "object", + }, + }, + }, + "slots": map[string]interface{}{ + "minimum": 10, + "type": "integer", + }, + "algorithm": map[string]interface{}{ + "enum": []interface{}{ + "round-robin", + "consistent-hashing", + "least-connections", + }, + "type": "string", + }, + "hash_fallback": map[string]interface{}{ + "type": "string", + }, + "hash_on_header": map[string]interface{}{ + "type": "string", + }, + "host_header": map[string]interface{}{ + "type": "string", + }, + }, + "type": "object", + }, + "proxy": map[string]interface{}{ + "properties": map[string]interface{}{ + "connect_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "path": map[string]interface{}{ + "pattern": "^/.*$", + "type": "string", + }, + "protocol": map[string]interface{}{ + "enum": []interface{}{ + "http", + "https", + "grpc", + "grpcs", + }, + "type": "string", + }, + "read_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "retries": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "write_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + "type": "object", + }, + "route": map[string]interface{}{ + "properties": map[string]interface{}{ + "protocols": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + "enum": []interface{}{ + "http", + "https", + "grpc", + "grpcs", + }, + }, + "type": "array", + }, + "regex_priority": map[string]interface{}{ + "type": "integer", + }, + "strip_path": map[string]interface{}{ + "type": "boolean", + }, + "headers": map[string]interface{}{ + "additionalProperties": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + }, + "type": "array", + }, + "type": "object", + }, + "https_redirect_status_code": map[string]interface{}{ + "type": "integer", + }, + "methods": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + }, + "type": "array", + }, + "preserve_host": map[string]interface{}{ + "type": "boolean", + }, + }, + }, + }, + }, + }, + }, + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "helm.sh/chart": "kong-0.36.6", + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + }, + "name": "kongingresses.configuration.konghq.com", + }, + }, + } + + customResourceDefinition5 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + }, + "name": "kongconsumers.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "kind": "KongConsumer", + "plural": "kongconsumers", + "shortNames": []interface{}{ + "kc", + }, + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "credentials": map[string]interface{}{ + "type": "array", + "items": map[string]interface{}{ + "type": "string", + }, + }, + "custom_id": map[string]interface{}{ + "type": "string", + }, + "username": map[string]interface{}{ + "type": "string", + }, + }, + }, + }, + "version": "v1", + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "JSONPath": ".username", + "description": "Username of a Kong Consumer", + "name": "Username", + "type": "string", + }, + map[string]interface{}{ + "JSONPath": ".metadata.creationTimestamp", + "description": "Age", + "name": "Age", + "type": "date", + }, + }, + }, + }, + } + + customResourceDefinition6 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + "app.kubernetes.io/instance": "release-name", + }, + "name": "kongcredentials.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "JSONPath": ".type", + "description": "Type of credential", + "name": "Credential-type", + "type": "string", + }, + map[string]interface{}{ + "description": "Age", + "name": "Age", + "type": "date", + "JSONPath": ".metadata.creationTimestamp", + }, + map[string]interface{}{ + "JSONPath": ".consumerRef", + "description": "Owner of the credential", + "name": "Consumer-Ref", + "type": "string", + }, + }, + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "kind": "KongCredential", + "plural": "kongcredentials", + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "consumerRef": map[string]interface{}{ + "type": "string", + }, + "type": map[string]interface{}{ + "type": "string", + }, + }, + "required": []interface{}{ + "consumerRef", + "type", + }, + }, + }, + "version": "v1", + }, + }, + } + + customResourceDefinition7 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + "helm.sh/chart": "kong-0.36.6", + }, + "name": "kongplugins.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "names": map[string]interface{}{ + "kind": "KongPlugin", + "plural": "kongplugins", + "shortNames": []interface{}{ + "kp", + }, + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "config": map[string]interface{}{ + "type": "object", + }, + "disabled": map[string]interface{}{ + "type": "boolean", + }, + "plugin": map[string]interface{}{ + "type": "string", + }, + "protocols": map[string]interface{}{ + "items": map[string]interface{}{ + "enum": []interface{}{ + "http", + "https", + "tcp", + "tls", + "grpc", + "grpcs", + }, + "type": "string", + }, + "type": "array", + }, + "run_on": map[string]interface{}{ + "type": "string", + "enum": []interface{}{ + "first", + "second", + "all", + }, + }, + }, + "required": []interface{}{ + "plugin", + }, + }, + }, + "version": "v1", + "additionalPrinterColumns": []interface{}{ + map[string]interface{}{ + "description": "Name of the plugin", + "name": "Plugin-Type", + "type": "string", + "JSONPath": ".plugin", + }, + map[string]interface{}{ + "description": "Age", + "name": "Age", + "type": "date", + "JSONPath": ".metadata.creationTimestamp", + }, + map[string]interface{}{ + "priority": 1, + "type": "boolean", + "JSONPath": ".disabled", + "description": "Indicates if the plugin is disabled", + "name": "Disabled", + }, + map[string]interface{}{ + "JSONPath": ".config", + "description": "Configuration of the plugin", + "name": "Config", + "priority": 1, + "type": "string", + }, + }, + "group": "configuration.konghq.com", + }, + }, + } + + customResourceDefinition8 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "apiextensions.k8s.io/v1beta1", + "kind": "CustomResourceDefinition", + "metadata": map[string]interface{}{ + "labels": map[string]interface{}{ + "helm.sh/chart": "kong-0.36.6", + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/managed-by": "Helm", + "app.kubernetes.io/name": "kong", + "app.kubernetes.io/version": "1.4", + }, + "name": "kongingresses.configuration.konghq.com", + }, + "spec": map[string]interface{}{ + "group": "configuration.konghq.com", + "names": map[string]interface{}{ + "plural": "kongingresses", + "shortNames": []interface{}{ + "ki", + }, + "kind": "KongIngress", + }, + "scope": "Namespaced", + "validation": map[string]interface{}{ + "openAPIV3Schema": map[string]interface{}{ + "properties": map[string]interface{}{ + "proxy": map[string]interface{}{ + "properties": map[string]interface{}{ + "path": map[string]interface{}{ + "pattern": "^/.*$", + "type": "string", + }, + "protocol": map[string]interface{}{ + "type": "string", + "enum": []interface{}{ + "http", + "https", + "grpc", + "grpcs", + }, + }, + "read_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "retries": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "write_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "connect_timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + "type": "object", + }, + "route": map[string]interface{}{ + "properties": map[string]interface{}{ + "https_redirect_status_code": map[string]interface{}{ + "type": "integer", + }, + "methods": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + }, + "type": "array", + }, + "preserve_host": map[string]interface{}{ + "type": "boolean", + }, + "protocols": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + "enum": []interface{}{ + "http", + "https", + "grpc", + "grpcs", + }, + }, + "type": "array", + }, + "regex_priority": map[string]interface{}{ + "type": "integer", + }, + "strip_path": map[string]interface{}{ + "type": "boolean", + }, + "headers": map[string]interface{}{ + "additionalProperties": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "string", + }, + "type": "array", + }, + "type": "object", + }, + }, + }, + "upstream": map[string]interface{}{ + "properties": map[string]interface{}{ + "algorithm": map[string]interface{}{ + "enum": []interface{}{ + "round-robin", + "consistent-hashing", + "least-connections", + }, + "type": "string", + }, + "hash_fallback_header": map[string]interface{}{ + "type": "string", + }, + "hash_on_cookie": map[string]interface{}{ + "type": "string", + }, + "hash_on_cookie_path": map[string]interface{}{ + "type": "string", + }, + "host_header": map[string]interface{}{ + "type": "string", + }, + "hash_fallback": map[string]interface{}{ + "type": "string", + }, + "hash_on": map[string]interface{}{ + "type": "string", + }, + "hash_on_header": map[string]interface{}{ + "type": "string", + }, + "healthchecks": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "active": map[string]interface{}{ + "properties": map[string]interface{}{ + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "unhealthy": map[string]interface{}{ + "properties": map[string]interface{}{ + "http_failures": map[string]interface{}{ + "type": "integer", + "minimum": 0, + }, + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "tcp_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + "type": "object", + }, + "concurrency": map[string]interface{}{ + "minimum": 1, + "type": "integer", + }, + "healthy": map[string]interface{}{ + "properties": map[string]interface{}{ + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "successes": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + "type": "object", + }, + "http_path": map[string]interface{}{ + "pattern": "^/.*$", + "type": "string", + }, + }, + "type": "object", + }, + "passive": map[string]interface{}{ + "properties": map[string]interface{}{ + "healthy": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "http_statuses": map[string]interface{}{ + "items": map[string]interface{}{ + "type": "integer", + }, + "type": "array", + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "successes": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + }, + "unhealthy": map[string]interface{}{ + "type": "object", + "properties": map[string]interface{}{ + "http_statuses": map[string]interface{}{ + "type": "array", + "items": map[string]interface{}{ + "type": "integer", + }, + }, + "interval": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "tcp_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "timeout": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + "http_failures": map[string]interface{}{ + "minimum": 0, + "type": "integer", + }, + }, + }, + }, + "type": "object", + }, + }, + }, + "slots": map[string]interface{}{ + "minimum": 10, + "type": "integer", + }, + }, + "type": "object", + }, + }, + }, + }, + "version": "v1", + }, + }, + } + + return []*unstructured.Unstructured{customResourceDefinition1, customResourceDefinition2, customResourceDefinition3, customResourceDefinition4, customResourceDefinition5, customResourceDefinition6, customResourceDefinition7, customResourceDefinition8} +} \ No newline at end of file diff --git a/depRicKubernetesOperator/internal/controller/getEndPoints.go b/depRicKubernetesOperator/internal/controller/getEndPoints.go new file mode 100644 index 0000000..b426a89 --- /dev/null +++ b/depRicKubernetesOperator/internal/controller/getEndPoints.go @@ -0,0 +1,133 @@ +package controller + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + rbacv1 "k8s.io/api/rbac/v1" +) + + +func GetEndpoints() []*unstructured.Unstructured { + + endpoints1 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Endpoints", + "metadata": map[string]interface{}{ + "name": "aux-entry", + "namespace": "ricplt", + }, + "subsets": []interface{}{ + map[string]interface{}{ + "ports": []interface{}{ + map[string]interface{}{ + "name": "aux-entry-http-ingress-port", + "port": 32080, + }, + map[string]interface{}{ + "name": "aux-entry-https-ingress-port", + "port": 32443, + }, + }, + "addresses": []interface{}{ + map[string]interface{}{ + "ip": "10.0.0.1", + }, + }, + }, + }, + }, + } + + endpoints2 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Endpoints", + "metadata": map[string]interface{}{ + "name": "aux-entry", + "namespace": "ricxapp", + }, + "subsets": []interface{}{ + map[string]interface{}{ + "addresses": []interface{}{ + map[string]interface{}{ + "ip": "10.0.0.1", + }, + }, + "ports": []interface{}{ + map[string]interface{}{ + "name": "aux-entry-http-ingress-port", + "port": 32080, + }, + map[string]interface{}{ + "port": 32443, + "name": "aux-entry-https-ingress-port", + }, + }, + }, + }, + }, + } + + endpoints3 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Endpoints", + "metadata": map[string]interface{}{ + "namespace": "ricplt", + "name": "aux-entry", + }, + "subsets": []interface{}{ + map[string]interface{}{ + "addresses": []interface{}{ + map[string]interface{}{ + "ip": "10.0.0.1", + }, + }, + "ports": []interface{}{ + map[string]interface{}{ + "name": "aux-entry-http-ingress-port", + "port": 32080, + }, + map[string]interface{}{ + "name": "aux-entry-https-ingress-port", + "port": 32443, + }, + }, + }, + }, + }, + } + + endpoints4 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "v1", + "kind": "Endpoints", + "metadata": map[string]interface{}{ + "name": "aux-entry", + "namespace": "ricxapp", + }, + "subsets": []interface{}{ + map[string]interface{}{ + "addresses": []interface{}{ + map[string]interface{}{ + "ip": "10.0.0.1", + }, + }, + "ports": []interface{}{ + map[string]interface{}{ + "name": "aux-entry-http-ingress-port", + "port": 32080, + }, + map[string]interface{}{ + "name": "aux-entry-https-ingress-port", + "port": 32443, + }, + }, + }, + }, + }, + } + + return []*unstructured.Unstructured{endpoints1, endpoints2, endpoints3, endpoints4} +} \ No newline at end of file diff --git a/depRicKubernetesOperator/internal/controller/getJob.go b/depRicKubernetesOperator/internal/controller/getJob.go new file mode 100644 index 0000000..402fe2e --- /dev/null +++ b/depRicKubernetesOperator/internal/controller/getJob.go @@ -0,0 +1,73 @@ +package controller + +import ( + "context" + "fmt" +) + + +func GetJob() []*unstructured.Unstructured { + + job1 := &unstructured.Unstructured{ + Object: map[string]interface{}{ + "apiVersion": "batch/v1", + "kind": "Job", + "metadata": map[string]interface{}{ + "name": "tiller-secret-generator", + "namespace": "ricinfra", + }, + "spec": map[string]interface{}{ + "template": map[string]interface{}{ + "spec": map[string]interface{}{ + "containers": []interface{}{ + map[string]interface{}{ + "env": []interface{}{ + map[string]interface{}{ + "name": "ENTITIES", + "value": "ricxapp-tiller-secret ricxapp-helm-secret", + }, + map[string]interface{}{ + "name": "TILLER_KEY_NAME", + "value": "ricxapp-tiller-secret.key.pem", + }, + map[string]interface{}{ + "name": "TILLER_CERT_NAME", + "value": "ricxapp-tiller-secret.cert.pem", + }, + map[string]interface{}{ + "name": "HELM_KEY_NAME", + "value": "ricxapp-helm-secret.key.pem", + }, + map[string]interface{}{ + "name": "HELM_CERT_NAME", + "value": "ricxapp-helm-secret.cert.pem", + }, + map[string]interface{}{ + "name": "TILLER_CN", + "value": "service-tiller-ricxapp", + }, + map[string]interface{}{ + "name": "CLUSTER_SERVER", + "value": "https://kubernetes.default.svc.cluster.local/", + }, + }, + "image": "nexus3.o-ran-sc.org:10002/o-ran-sc/it-dep-secret:0.0.2", + "imagePullPolicy": "IfNotPresent", + "name": "tiller-secret-generator", + }, + }, + "imagePullSecrets": []interface{}{ + map[string]interface{}{ + "name": "secret-nexus3-o-ran-sc-org-10002-o-ran-sc", + }, + }, + "restartPolicy": "Never", + "serviceAccountName": "tiller-secret-creator-xzhjjg", + }, + }, + }, + }, + } + + return []*unstructured.Unstructured{job1} +} \ No newline at end of file diff --git a/depRicKubernetesOperator/internal/controller/getStatefulSet.go b/depRicKubernetesOperator/internal/controller/getStatefulSet.go new file mode 100644 index 0000000..b18f627 --- /dev/null +++ b/depRicKubernetesOperator/internal/controller/getStatefulSet.go @@ -0,0 +1,284 @@ +package controller + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + + + +func GetStatefulSet() []*appsv1.StatefulSet { + + statefulSet1 := &appsv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "ricplt", + Labels: map[string]string{ + "app": "ricplt-dbaas", + "chart": "dbaas-2.0.0", + "heritage": "Helm", + "release": "release-name", + }, + Name: "statefulset-ricplt-dbaas-server", + }, + Spec: appsv1.StatefulSetSpec{ + PodManagementPolicy: appsv1.PodManagementPolicyType("OrderedReady"), + Replicas: int32Ptr(1), + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app": "ricplt-dbaas", + "release": "release-name", + }, + }, + ServiceName: "service-ricplt-dbaas-tcp", + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app": "ricplt-dbaas", + "release": "release-name", + }, + }, + Spec: corev1.PodSpec{ + ImagePullSecrets: []corev1.LocalObjectReference{ + + corev1.LocalObjectReference{ + Name: "secret-nexus3-o-ran-sc-org-10002-o-ran-sc", + }, + }, + ShareProcessNamespace: boolPtr(true), + TerminationGracePeriodSeconds: int64Ptr(5), + Volumes: []corev1.Volume{ + + corev1.Volume{ + Name: "config", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "configmap-ricplt-dbaas-config", + }, + }, + }, + }, + }, + Containers: []corev1.Container{ + + corev1.Container{ + Command: []string{ + + "redis-server", + }, + EnvFrom: []corev1.EnvFromSource{ + + corev1.EnvFromSource{ + ConfigMapRef: &corev1.ConfigMapEnvSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "configmap-ricplt-dbaas-appconfig", + }, + }, + }, + }, + LivenessProbe: &corev1.Probe{ + PeriodSeconds: 5, + ProbeHandler: corev1.ProbeHandler{ + Exec: &corev1.ExecAction{ + Command: []string{ + + "/bin/sh", + "-c", + "timeout 10 redis-cli -p 6379 ping", + }, + }, + }, + InitialDelaySeconds: 15, + }, + Stdin: false, + TTY: false, + VolumeMounts: []corev1.VolumeMount{ + + corev1.VolumeMount{ + MountPath: "/data", + Name: "config", + ReadOnly: false, + }, + }, + Args: []string{ + + "/data/redis.conf", + }, + Image: "nexus3.o-ran-sc.org:10002/o-ran-sc/ric-plt-dbaas:0.6.1", + Name: "container-ricplt-dbaas-redis", + Ports: []corev1.ContainerPort{ + + corev1.ContainerPort{ + ContainerPort: 6379, + Name: "redis", + }, + }, + ReadinessProbe: &corev1.Probe{ + InitialDelaySeconds: 15, + PeriodSeconds: 5, + ProbeHandler: corev1.ProbeHandler{ + Exec: &corev1.ExecAction{ + Command: []string{ + + "/bin/sh", + "-c", + "timeout 10 redis-cli -p 6379 ping", + }, + }, + }, + }, + StdinOnce: false, + }, + }, + HostIPC: false, + HostNetwork: false, + HostPID: false, + }, + }, + UpdateStrategy: appsv1.StatefulSetUpdateStrategy{ + Type: appsv1.StatefulSetUpdateStrategyType("RollingUpdate"), + }, + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "apps/v1", + Kind: "StatefulSet", + }, + } + + statefulSet2 := &appsv1.StatefulSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "redis-cluster", + }, + Spec: appsv1.StatefulSetSpec{ + Replicas: int32Ptr(9), + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/name": "redis-cluster", + }, + }, + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/name": "redis-cluster", + }, + }, + Spec: corev1.PodSpec{ + Volumes: []corev1.Volume{ + + corev1.Volume{ + Name: "conf", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + DefaultMode: int32Ptr(493), + LocalObjectReference: corev1.LocalObjectReference{ + Name: "redis-cluster-cm", + }, + }, + }, + }, + }, + Containers: []corev1.Container{ + + corev1.Container{ + Stdin: false, + StdinOnce: false, + TTY: false, + Command: []string{ + + "/conf/update-node.sh", + "redis-server", + "/conf/redis.conf", + }, + Name: "redis", + Ports: []corev1.ContainerPort{ + + corev1.ContainerPort{ + ContainerPort: 6379, + Name: "client", + }, + corev1.ContainerPort{ + Name: "gossip", + ContainerPort: 16379, + }, + }, + VolumeMounts: []corev1.VolumeMount{ + + corev1.VolumeMount{ + Name: "conf", + ReadOnly: false, + MountPath: "/conf", + }, + corev1.VolumeMount{ + MountPath: "/data", + Name: "data", + ReadOnly: false, + }, + }, + Env: []corev1.EnvVar{ + + corev1.EnvVar{ + Name: "POD_IP", + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + FieldPath: "status.podIP", + }, + }, + }, + }, + Image: "redis:5.0.1-alpine", + ImagePullPolicy: corev1.PullPolicy("IfNotPresent"), + }, + }, + HostIPC: false, + HostNetwork: false, + HostPID: false, + TopologySpreadConstraints: []corev1.TopologySpreadConstraint{ + + corev1.TopologySpreadConstraint{ + TopologyKey: "kubernetes.io/hostname", + WhenUnsatisfiable: corev1.UnsatisfiableConstraintAction("DoNotSchedule"), + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/instance": "release-name", + "app.kubernetes.io/name": "redis-cluster", + }, + }, + MaxSkew: 1, + }, + }, + }, + }, + VolumeClaimTemplates: []corev1.PersistentVolumeClaim{ + + corev1.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app.kubernetes.io/name": "redis-cluster", + "app.kubernetes.io/instance": "release-name", + }, + Name: "data", + }, + Spec: corev1.PersistentVolumeClaimSpec{ + AccessModes: []corev1.PersistentVolumeAccessMode{ + + corev1.PersistentVolumeAccessMode("ReadWriteOnce"), + }, + Resources: corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + "storage": resource.MustParse("1Gi"), + }, + }, + }, + }, + }, + }, + TypeMeta: metav1.TypeMeta{ + APIVersion: "apps/v1", + Kind: "StatefulSet", + }, + } + + return []*appsv1.StatefulSet{statefulSet1, statefulSet2} +} \ No newline at end of file