diff --git a/pkg/splunk/enterprise/ingestorcluster_test.go b/pkg/splunk/enterprise/ingestorcluster_test.go index bee3df4d6..ef0c823f8 100644 --- a/pkg/splunk/enterprise/ingestorcluster_test.go +++ b/pkg/splunk/enterprise/ingestorcluster_test.go @@ -367,7 +367,7 @@ func TestGetIngestorStatefulSet(t *testing.T) { // Define additional service port in CR and verify the statefulset has the new port cr.Spec.ServiceTemplate.Spec.Ports = []corev1.ServicePort{{Name: "user-defined", Port: 32000, Protocol: "UDP"}} - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-test-ingestor","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"ownerReferences":[{"apiVersion":"","kind":"IngestorCluster","name":"test","uid":"","controller":true}]},"spec":{"replicas":3,"selector":{"matchLabels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-test-ingestor-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"http-hec","containerPort":8088,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"},{"name":"tcp-s2s","containerPort":9997,"protocol":"TCP"},{"name":"user-defined","containerPort":32000,"protocol":"UDP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_standalone"},{"name":"SPLUNK_DECLARATIVE_ADMIN_PASSWORD","value":"true"},{"name":"SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH","value":"/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh"},{"name":"SPLUNK_GENERAL_TERMS","value":"--accept-sgt-current-at-splunk-com"},{"name":"SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH","value":"true"}],"resources":{"limits":{"cpu":"4","memory":"8Gi"},"requests":{"cpu":"100m","memory":"512Mi"}},"volumeMounts":[{"name":"pvc-etc","mountPath":"/opt/splunk/etc"},{"name":"pvc-var","mountPath":"/opt/splunk/var"},{"name":"splunk-test-probe-configmap","mountPath":"/mnt/probes"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"}],"livenessProbe":{"exec":{"command":["/mnt/probes/livenessProbe.sh"]},"initialDelaySeconds":30,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":3},"readinessProbe":{"exec":{"command":["/mnt/probes/readinessProbe.sh"]},"initialDelaySeconds":10,"timeoutSeconds":5,"periodSeconds":5,"failureThreshold":3},"startupProbe":{"exec":{"command":["/mnt/probes/startupProbe.sh"]},"initialDelaySeconds":40,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":12},"imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{"add":["NET_BIND_SERVICE"],"drop":["ALL"]},"privileged":false,"runAsUser":41812,"runAsNonRoot":true,"allowPrivilegeEscalation":false,"seccompProfile":{"type":"RuntimeDefault"}}}],"securityContext":{"runAsUser":41812,"runAsNonRoot":true,"fsGroup":41812,"fsGroupChangePolicy":"OnRootMismatch"},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/instance","operator":"In","values":["splunk-test-ingestor"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-test-ingestor-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_ingestor_base_1.json")) // Create a service account current := corev1.ServiceAccount{ @@ -378,7 +378,7 @@ func TestGetIngestorStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-test-ingestor","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"ownerReferences":[{"apiVersion":"","kind":"IngestorCluster","name":"test","uid":"","controller":true}]},"spec":{"replicas":3,"selector":{"matchLabels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-test-ingestor-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"http-hec","containerPort":8088,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"},{"name":"tcp-s2s","containerPort":9997,"protocol":"TCP"},{"name":"user-defined","containerPort":32000,"protocol":"UDP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_standalone"},{"name":"SPLUNK_DECLARATIVE_ADMIN_PASSWORD","value":"true"},{"name":"SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH","value":"/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh"},{"name":"SPLUNK_GENERAL_TERMS","value":"--accept-sgt-current-at-splunk-com"},{"name":"SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH","value":"true"}],"resources":{"limits":{"cpu":"4","memory":"8Gi"},"requests":{"cpu":"100m","memory":"512Mi"}},"volumeMounts":[{"name":"pvc-etc","mountPath":"/opt/splunk/etc"},{"name":"pvc-var","mountPath":"/opt/splunk/var"},{"name":"splunk-test-probe-configmap","mountPath":"/mnt/probes"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"}],"livenessProbe":{"exec":{"command":["/mnt/probes/livenessProbe.sh"]},"initialDelaySeconds":30,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":3},"readinessProbe":{"exec":{"command":["/mnt/probes/readinessProbe.sh"]},"initialDelaySeconds":10,"timeoutSeconds":5,"periodSeconds":5,"failureThreshold":3},"startupProbe":{"exec":{"command":["/mnt/probes/startupProbe.sh"]},"initialDelaySeconds":40,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":12},"imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{"add":["NET_BIND_SERVICE"],"drop":["ALL"]},"privileged":false,"runAsUser":41812,"runAsNonRoot":true,"allowPrivilegeEscalation":false,"seccompProfile":{"type":"RuntimeDefault"}}}],"serviceAccountName":"defaults","securityContext":{"runAsUser":41812,"runAsNonRoot":true,"fsGroup":41812,"fsGroupChangePolicy":"OnRootMismatch"},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/instance","operator":"In","values":["splunk-test-ingestor"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-test-ingestor-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_ingestor_base_2.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -387,12 +387,12 @@ func TestGetIngestorStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-test-ingestor","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"ownerReferences":[{"apiVersion":"","kind":"IngestorCluster","name":"test","uid":"","controller":true}]},"spec":{"replicas":3,"selector":{"matchLabels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-test-ingestor-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"http-hec","containerPort":8088,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"},{"name":"tcp-s2s","containerPort":9997,"protocol":"TCP"},{"name":"user-defined","containerPort":32000,"protocol":"UDP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_standalone"},{"name":"SPLUNK_DECLARATIVE_ADMIN_PASSWORD","value":"true"},{"name":"SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH","value":"/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh"},{"name":"SPLUNK_GENERAL_TERMS","value":"--accept-sgt-current-at-splunk-com"},{"name":"SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH","value":"true"}],"resources":{"limits":{"cpu":"4","memory":"8Gi"},"requests":{"cpu":"100m","memory":"512Mi"}},"volumeMounts":[{"name":"pvc-etc","mountPath":"/opt/splunk/etc"},{"name":"pvc-var","mountPath":"/opt/splunk/var"},{"name":"splunk-test-probe-configmap","mountPath":"/mnt/probes"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"}],"livenessProbe":{"exec":{"command":["/mnt/probes/livenessProbe.sh"]},"initialDelaySeconds":30,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":3},"readinessProbe":{"exec":{"command":["/mnt/probes/readinessProbe.sh"]},"initialDelaySeconds":10,"timeoutSeconds":5,"periodSeconds":5,"failureThreshold":3},"startupProbe":{"exec":{"command":["/mnt/probes/startupProbe.sh"]},"initialDelaySeconds":40,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":12},"imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{"add":["NET_BIND_SERVICE"],"drop":["ALL"]},"privileged":false,"runAsUser":41812,"runAsNonRoot":true,"allowPrivilegeEscalation":false,"seccompProfile":{"type":"RuntimeDefault"}}}],"serviceAccountName":"defaults","securityContext":{"runAsUser":41812,"runAsNonRoot":true,"fsGroup":41812,"fsGroupChangePolicy":"OnRootMismatch"},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/instance","operator":"In","values":["splunk-test-ingestor"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-test-ingestor-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_ingestor_base_3.json")) // Add additional label to cr metadata to transfer to the statefulset cr.ObjectMeta.Labels = make(map[string]string) cr.ObjectMeta.Labels["app.kubernetes.io/test-extra-label"] = "test-extra-label-value" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-test-ingestor","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"IngestorCluster","name":"test","uid":"","controller":true}]},"spec":{"replicas":3,"selector":{"matchLabels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-test-ingestor-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"http-hec","containerPort":8088,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"},{"name":"tcp-s2s","containerPort":9997,"protocol":"TCP"},{"name":"user-defined","containerPort":32000,"protocol":"UDP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_standalone"},{"name":"SPLUNK_DECLARATIVE_ADMIN_PASSWORD","value":"true"},{"name":"SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH","value":"/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh"},{"name":"SPLUNK_GENERAL_TERMS","value":"--accept-sgt-current-at-splunk-com"},{"name":"SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH","value":"true"}],"resources":{"limits":{"cpu":"4","memory":"8Gi"},"requests":{"cpu":"100m","memory":"512Mi"}},"volumeMounts":[{"name":"pvc-etc","mountPath":"/opt/splunk/etc"},{"name":"pvc-var","mountPath":"/opt/splunk/var"},{"name":"splunk-test-probe-configmap","mountPath":"/mnt/probes"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"}],"livenessProbe":{"exec":{"command":["/mnt/probes/livenessProbe.sh"]},"initialDelaySeconds":30,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":3},"readinessProbe":{"exec":{"command":["/mnt/probes/readinessProbe.sh"]},"initialDelaySeconds":10,"timeoutSeconds":5,"periodSeconds":5,"failureThreshold":3},"startupProbe":{"exec":{"command":["/mnt/probes/startupProbe.sh"]},"initialDelaySeconds":40,"timeoutSeconds":30,"periodSeconds":30,"failureThreshold":12},"imagePullPolicy":"IfNotPresent","securityContext":{"capabilities":{"add":["NET_BIND_SERVICE"],"drop":["ALL"]},"privileged":false,"runAsUser":41812,"runAsNonRoot":true,"allowPrivilegeEscalation":false,"seccompProfile":{"type":"RuntimeDefault"}}}],"serviceAccountName":"defaults","securityContext":{"runAsUser":41812,"runAsNonRoot":true,"fsGroup":41812,"fsGroupChangePolicy":"OnRootMismatch"},"affinity":{"podAntiAffinity":{"preferredDuringSchedulingIgnoredDuringExecution":[{"weight":100,"podAffinityTerm":{"labelSelector":{"matchExpressions":[{"key":"app.kubernetes.io/instance","operator":"In","values":["splunk-test-ingestor"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"ingestor","app.kubernetes.io/instance":"splunk-test-ingestor","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"ingestor","app.kubernetes.io/part-of":"splunk-test-ingestor","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-test-ingestor-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_ingestor_base_4.json")) } func TestGetChangedBusFieldsForIngestor(t *testing.T) { diff --git a/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_1.json new file mode 100644 index 000000000..b3a1330dd --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_1.json @@ -0,0 +1,207 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-test-ingestor", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "IngestorCluster", + "name": "test", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 3, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-test-ingestor-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { "name": "http-splunkweb", "containerPort": 8000, "protocol": "TCP" }, + { "name": "http-hec", "containerPort": 8088, "protocol": "TCP" }, + { "name": "https-splunkd", "containerPort": 8089, "protocol": "TCP" }, + { "name": "tcp-s2s", "containerPort": 9997, "protocol": "TCP" }, + { "name": "user-defined", "containerPort": 32000, "protocol": "UDP" } + ], + "env": [ + { "name": "SPLUNK_HOME", "value": "/opt/splunk" }, + { "name": "SPLUNK_START_ARGS", "value": "--accept-license" }, + { "name": "SPLUNK_DEFAULTS_URL", "value": "/mnt/splunk-secrets/default.yml" }, + { "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", "value": "false" }, + { "name": "SPLUNK_ROLE", "value": "splunk_ingestor" }, + { "name": "SPLUNK_DECLARATIVE_ADMIN_PASSWORD", "value": "true" }, + { "name": "SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH", "value": "/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh" }, + { "name": "SPLUNK_GENERAL_TERMS", "value": "--accept-sgt-current-at-splunk-com" }, + { "name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH", "value": "true" } + ], + "resources": { + "limits": { "cpu": "4", "memory": "8Gi" }, + "requests": { "cpu": "100m", "memory": "512Mi" } + }, + "volumeMounts": [ + { "name": "pvc-etc", "mountPath": "/opt/splunk/etc" }, + { "name": "pvc-var", "mountPath": "/opt/splunk/var" }, + { "name": "splunk-test-probe-configmap", "mountPath": "/mnt/probes" }, + { "name": "mnt-splunk-secrets", "mountPath": "/mnt/splunk-secrets" } + ], + "livenessProbe": { + "exec": { "command": ["/mnt/probes/livenessProbe.sh"] }, + "initialDelaySeconds": 30, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { "command": ["/mnt/probes/readinessProbe.sh"] }, + "initialDelaySeconds": 10, + "timeoutSeconds": 5, + "periodSeconds": 5, + "failureThreshold": 3 + }, + "startupProbe": { + "exec": { "command": ["/mnt/probes/startupProbe.sh"] }, + "initialDelaySeconds": 40, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 12 + }, + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": { "add": ["NET_BIND_SERVICE"], "drop": ["ALL"] }, + "privileged": false, + "runAsUser": 41812, + "runAsNonRoot": true, + "allowPrivilegeEscalation": false, + "seccompProfile": { "type": "RuntimeDefault" } + } + } + ], + "securityContext": { + "runAsUser": 41812, + "runAsNonRoot": true, + "fsGroup": 41812, + "fsGroupChangePolicy": "OnRootMismatch" + }, + "affinity": { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [ + { + "weight": 100, + "podAffinityTerm": { + "labelSelector": { + "matchExpressions": [ + { + "key": "app.kubernetes.io/instance", + "operator": "In", + "values": ["splunk-test-ingestor"] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "10Gi" } } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "100Gi" } } + }, + "status": {} + } + ], + "serviceName": "splunk-test-ingestor-headless", + "podManagementPolicy": "Parallel", + "updateStrategy": { "type": "OnDelete" } + }, + "status": { "replicas": 0, "availableReplicas": 0 } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_2.json new file mode 100644 index 000000000..973708b2d --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_2.json @@ -0,0 +1,208 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-test-ingestor", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "IngestorCluster", + "name": "test", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 3, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-test-ingestor-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { "name": "http-splunkweb", "containerPort": 8000, "protocol": "TCP" }, + { "name": "http-hec", "containerPort": 8088, "protocol": "TCP" }, + { "name": "https-splunkd", "containerPort": 8089, "protocol": "TCP" }, + { "name": "tcp-s2s", "containerPort": 9997, "protocol": "TCP" }, + { "name": "user-defined", "containerPort": 32000, "protocol": "UDP" } + ], + "env": [ + { "name": "SPLUNK_HOME", "value": "/opt/splunk" }, + { "name": "SPLUNK_START_ARGS", "value": "--accept-license" }, + { "name": "SPLUNK_DEFAULTS_URL", "value": "/mnt/splunk-secrets/default.yml" }, + { "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", "value": "false" }, + { "name": "SPLUNK_ROLE", "value": "splunk_ingestor" }, + { "name": "SPLUNK_DECLARATIVE_ADMIN_PASSWORD", "value": "true" }, + { "name": "SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH", "value": "/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh" }, + { "name": "SPLUNK_GENERAL_TERMS", "value": "--accept-sgt-current-at-splunk-com" }, + { "name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH", "value": "true" } + ], + "resources": { + "limits": { "cpu": "4", "memory": "8Gi" }, + "requests": { "cpu": "100m", "memory": "512Mi" } + }, + "volumeMounts": [ + { "name": "pvc-etc", "mountPath": "/opt/splunk/etc" }, + { "name": "pvc-var", "mountPath": "/opt/splunk/var" }, + { "name": "splunk-test-probe-configmap", "mountPath": "/mnt/probes" }, + { "name": "mnt-splunk-secrets", "mountPath": "/mnt/splunk-secrets" } + ], + "livenessProbe": { + "exec": { "command": ["/mnt/probes/livenessProbe.sh"] }, + "initialDelaySeconds": 30, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { "command": ["/mnt/probes/readinessProbe.sh"] }, + "initialDelaySeconds": 10, + "timeoutSeconds": 5, + "periodSeconds": 5, + "failureThreshold": 3 + }, + "startupProbe": { + "exec": { "command": ["/mnt/probes/startupProbe.sh"] }, + "initialDelaySeconds": 40, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 12 + }, + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": { "add": ["NET_BIND_SERVICE"], "drop": ["ALL"] }, + "privileged": false, + "runAsUser": 41812, + "runAsNonRoot": true, + "allowPrivilegeEscalation": false, + "seccompProfile": { "type": "RuntimeDefault" } + } + } + ], + "serviceAccountName": "defaults", + "securityContext": { + "runAsUser": 41812, + "runAsNonRoot": true, + "fsGroup": 41812, + "fsGroupChangePolicy": "OnRootMismatch" + }, + "affinity": { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [ + { + "weight": 100, + "podAffinityTerm": { + "labelSelector": { + "matchExpressions": [ + { + "key": "app.kubernetes.io/instance", + "operator": "In", + "values": ["splunk-test-ingestor"] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "10Gi" } } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "100Gi" } } + }, + "status": {} + } + ], + "serviceName": "splunk-test-ingestor-headless", + "podManagementPolicy": "Parallel", + "updateStrategy": { "type": "OnDelete" } + }, + "status": { "replicas": 0, "availableReplicas": 0 } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_3.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_3.json new file mode 100644 index 000000000..b8c271113 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_3.json @@ -0,0 +1,209 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-test-ingestor", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "IngestorCluster", + "name": "test", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 3, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-test-ingestor-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { "name": "http-splunkweb", "containerPort": 8000, "protocol": "TCP" }, + { "name": "http-hec", "containerPort": 8088, "protocol": "TCP" }, + { "name": "https-splunkd", "containerPort": 8089, "protocol": "TCP" }, + { "name": "tcp-s2s", "containerPort": 9997, "protocol": "TCP" }, + { "name": "user-defined", "containerPort": 32000, "protocol": "UDP" } + ], + "env": [ + { "name": "TEST_ENV_VAR", "value": "test_value" }, + { "name": "SPLUNK_HOME", "value": "/opt/splunk" }, + { "name": "SPLUNK_START_ARGS", "value": "--accept-license" }, + { "name": "SPLUNK_DEFAULTS_URL", "value": "/mnt/splunk-secrets/default.yml" }, + { "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", "value": "false" }, + { "name": "SPLUNK_ROLE", "value": "splunk_ingestor" }, + { "name": "SPLUNK_DECLARATIVE_ADMIN_PASSWORD", "value": "true" }, + { "name": "SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH", "value": "/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh" }, + { "name": "SPLUNK_GENERAL_TERMS", "value": "--accept-sgt-current-at-splunk-com" }, + { "name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH", "value": "true" } + ], + "resources": { + "limits": { "cpu": "4", "memory": "8Gi" }, + "requests": { "cpu": "100m", "memory": "512Mi" } + }, + "volumeMounts": [ + { "name": "pvc-etc", "mountPath": "/opt/splunk/etc" }, + { "name": "pvc-var", "mountPath": "/opt/splunk/var" }, + { "name": "splunk-test-probe-configmap", "mountPath": "/mnt/probes" }, + { "name": "mnt-splunk-secrets", "mountPath": "/mnt/splunk-secrets" } + ], + "livenessProbe": { + "exec": { "command": ["/mnt/probes/livenessProbe.sh"] }, + "initialDelaySeconds": 30, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { "command": ["/mnt/probes/readinessProbe.sh"] }, + "initialDelaySeconds": 10, + "timeoutSeconds": 5, + "periodSeconds": 5, + "failureThreshold": 3 + }, + "startupProbe": { + "exec": { "command": ["/mnt/probes/startupProbe.sh"] }, + "initialDelaySeconds": 40, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 12 + }, + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": { "add": ["NET_BIND_SERVICE"], "drop": ["ALL"] }, + "privileged": false, + "runAsUser": 41812, + "runAsNonRoot": true, + "allowPrivilegeEscalation": false, + "seccompProfile": { "type": "RuntimeDefault" } + } + } + ], + "serviceAccountName": "defaults", + "securityContext": { + "runAsUser": 41812, + "runAsNonRoot": true, + "fsGroup": 41812, + "fsGroupChangePolicy": "OnRootMismatch" + }, + "affinity": { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [ + { + "weight": 100, + "podAffinityTerm": { + "labelSelector": { + "matchExpressions": [ + { + "key": "app.kubernetes.io/instance", + "operator": "In", + "values": ["splunk-test-ingestor"] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "10Gi" } } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "100Gi" } } + }, + "status": {} + } + ], + "serviceName": "splunk-test-ingestor-headless", + "podManagementPolicy": "Parallel", + "updateStrategy": { "type": "OnDelete" } + }, + "status": { "replicas": 0, "availableReplicas": 0 } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_4.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_4.json new file mode 100644 index 000000000..0de3c614b --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_ingestor_base_4.json @@ -0,0 +1,213 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-test-ingestor", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "IngestorCluster", + "name": "test", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 3, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-test-ingestor-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { "name": "http-splunkweb", "containerPort": 8000, "protocol": "TCP" }, + { "name": "http-hec", "containerPort": 8088, "protocol": "TCP" }, + { "name": "https-splunkd", "containerPort": 8089, "protocol": "TCP" }, + { "name": "tcp-s2s", "containerPort": 9997, "protocol": "TCP" }, + { "name": "user-defined", "containerPort": 32000, "protocol": "UDP" } + ], + "env": [ + { "name": "TEST_ENV_VAR", "value": "test_value" }, + { "name": "SPLUNK_HOME", "value": "/opt/splunk" }, + { "name": "SPLUNK_START_ARGS", "value": "--accept-license" }, + { "name": "SPLUNK_DEFAULTS_URL", "value": "/mnt/splunk-secrets/default.yml" }, + { "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", "value": "false" }, + { "name": "SPLUNK_ROLE", "value": "splunk_ingestor" }, + { "name": "SPLUNK_DECLARATIVE_ADMIN_PASSWORD", "value": "true" }, + { "name": "SPLUNK_OPERATOR_K8_LIVENESS_DRIVER_FILE_PATH", "value": "/tmp/splunk_operator_k8s/probes/k8_liveness_driver.sh" }, + { "name": "SPLUNK_GENERAL_TERMS", "value": "--accept-sgt-current-at-splunk-com" }, + { "name": "SPLUNK_SKIP_CLUSTER_BUNDLE_PUSH", "value": "true" } + ], + "resources": { + "limits": { "cpu": "4", "memory": "8Gi" }, + "requests": { "cpu": "100m", "memory": "512Mi" } + }, + "volumeMounts": [ + { "name": "pvc-etc", "mountPath": "/opt/splunk/etc" }, + { "name": "pvc-var", "mountPath": "/opt/splunk/var" }, + { "name": "splunk-test-probe-configmap", "mountPath": "/mnt/probes" }, + { "name": "mnt-splunk-secrets", "mountPath": "/mnt/splunk-secrets" } + ], + "livenessProbe": { + "exec": { "command": ["/mnt/probes/livenessProbe.sh"] }, + "initialDelaySeconds": 30, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { "command": ["/mnt/probes/readinessProbe.sh"] }, + "initialDelaySeconds": 10, + "timeoutSeconds": 5, + "periodSeconds": 5, + "failureThreshold": 3 + }, + "startupProbe": { + "exec": { "command": ["/mnt/probes/startupProbe.sh"] }, + "initialDelaySeconds": 40, + "timeoutSeconds": 30, + "periodSeconds": 30, + "failureThreshold": 12 + }, + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": { "add": ["NET_BIND_SERVICE"], "drop": ["ALL"] }, + "privileged": false, + "runAsUser": 41812, + "runAsNonRoot": true, + "allowPrivilegeEscalation": false, + "seccompProfile": { "type": "RuntimeDefault" } + } + } + ], + "serviceAccountName": "defaults", + "securityContext": { + "runAsUser": 41812, + "runAsNonRoot": true, + "fsGroup": 41812, + "fsGroupChangePolicy": "OnRootMismatch" + }, + "affinity": { + "podAntiAffinity": { + "preferredDuringSchedulingIgnoredDuringExecution": [ + { + "weight": 100, + "podAffinityTerm": { + "labelSelector": { + "matchExpressions": [ + { + "key": "app.kubernetes.io/instance", + "operator": "In", + "values": ["splunk-test-ingestor"] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "10Gi" } } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "ingestor", + "app.kubernetes.io/instance": "splunk-test-ingestor", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "ingestor", + "app.kubernetes.io/part-of": "splunk-test-ingestor", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": ["ReadWriteOnce"], + "resources": { "requests": { "storage": "100Gi" } } + }, + "status": {} + } + ], + "serviceName": "splunk-test-ingestor-headless", + "podManagementPolicy": "Parallel", + "updateStrategy": { "type": "OnDelete" } + }, + "status": { "replicas": 0, "availableReplicas": 0 } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/types.go b/pkg/splunk/enterprise/types.go index 6ebd3df34..2282a1c90 100644 --- a/pkg/splunk/enterprise/types.go +++ b/pkg/splunk/enterprise/types.go @@ -251,7 +251,7 @@ func (instanceType InstanceType) ToRole() string { case SplunkMonitoringConsole: role = "splunk_monitor" case SplunkIngestor: - role = "splunk_standalone" // TODO: change this to a new role when we have one (splunk_ingestor) + role = "splunk_ingestor" } return role } diff --git a/pkg/splunk/enterprise/types_test.go b/pkg/splunk/enterprise/types_test.go index 1f30bd500..832691794 100644 --- a/pkg/splunk/enterprise/types_test.go +++ b/pkg/splunk/enterprise/types_test.go @@ -39,7 +39,7 @@ func TestInstanceType(t *testing.T) { SplunkLicenseMaster: splcommon.LicenseManagerRole, SplunkLicenseManager: splcommon.LicenseManagerRole, SplunkMonitoringConsole: "splunk_monitor", - SplunkIngestor: "splunk_standalone", // TODO: change this to a new role when we have one (splunk_ingestor) + SplunkIngestor: "splunk_ingestor", } for key, val := range instMap { if key.ToRole() != val {