diff --git a/pkg/splunk/enterprise/clustermanager_test.go b/pkg/splunk/enterprise/clustermanager_test.go index 4cdb2e94e..92eb22e7e 100644 --- a/pkg/splunk/enterprise/clustermanager_test.go +++ b/pkg/splunk/enterprise/clustermanager_test.go @@ -465,18 +465,18 @@ func TestGetClusterManagerStatefulSet(t *testing.T) { } configTester(t, "getClusterManagerStatefulSet", f, want) } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_base.json")) cr.Spec.LicenseManagerRef.Name = "stack1" cr.Spec.LicenseManagerRef.Namespace = "test" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_MASTER_URL","value":"splunk-stack1-license-manager-service.test.svc.cluster.local"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_base_1.json")) cr.Spec.LicenseManagerRef.Name = "" cr.Spec.LicenseURL = "/mnt/splunk.lic" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_base_2.json")) cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -487,7 +487,7 @@ func TestGetClusterManagerStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -496,12 +496,12 @@ func TestGetClusterManagerStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_with_service_account_1.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-stack1-cluster-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer","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"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer","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":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-manager","app.kubernetes.io/part-of":"splunk-stack1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_manager_with_service_account_2.json")) } func TestClusterManagerSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/clustermaster_test.go b/pkg/splunk/enterprise/clustermaster_test.go index ae2ca5b51..2439a4249 100644 --- a/pkg/splunk/enterprise/clustermaster_test.go +++ b/pkg/splunk/enterprise/clustermaster_test.go @@ -165,18 +165,18 @@ func TestGetClusterMasterStatefulSet(t *testing.T) { configTester(t, "getClusterMasterStatefulSet", f, want) } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_base.json")) cr.Spec.LicenseManagerRef.Name = "stack1" cr.Spec.LicenseManagerRef.Namespace = "test" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_MASTER_URL","value":"splunk-stack1-license-manager-service.test.svc.cluster.local"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_base_1.json")) cr.Spec.LicenseManagerRef.Name = "" cr.Spec.LicenseURL = "/mnt/splunk.lic" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"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_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_base_2.json")) cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -187,7 +187,7 @@ func TestGetClusterMasterStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -196,12 +196,12 @@ func TestGetClusterMasterStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_with_service_account_1.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-stack1-cluster-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer","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"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-cluster-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"localhost"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_cluster_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-cluster-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer","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":"indexer","app.kubernetes.io/instance":"splunk-stack1-cluster-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"cluster-master","app.kubernetes.io/part-of":"splunk-stack1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-cluster-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_cluster_master_with_service_account_2.json")) } func TestClusterMasterSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/configuration_test.go b/pkg/splunk/enterprise/configuration_test.go index 4deb1be98..3be6d0393 100644 --- a/pkg/splunk/enterprise/configuration_test.go +++ b/pkg/splunk/enterprise/configuration_test.go @@ -95,11 +95,11 @@ func TestGetSplunkService(t *testing.T) { configTester(t, fmt.Sprintf("getSplunkService(\"%s\",%t)", instanceType, isHeadless), f, want) } - test(SplunkIndexer, false, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-indexer-service","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"http-hec","protocol":"TCP","port":8088,"targetPort":8088},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089},{"name":"tcp-s2s","protocol":"TCP","port":9997,"targetPort":9997}],"selector":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"status":{"loadBalancer":{}}}`) - test(SplunkIndexer, true, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-indexer-headless","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"http-hec","protocol":"TCP","port":8088,"targetPort":8088},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089},{"name":"tcp-s2s","protocol":"TCP","port":9997,"targetPort":9997}],"selector":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"clusterIP":"None","type":"ClusterIP"},"status":{"loadBalancer":{}}}`) + test(SplunkIndexer, false, loadFixture(t, "splunk_indexer_service.json")) + test(SplunkIndexer, true, loadFixture(t, "splunk_indexer_headless.json")) // Multipart IndexerCluster - test part-of and instance labels for child part cr.Spec.ClusterManagerRef.Name = "cluster1" - test(SplunkIndexer, false, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-indexer-service","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-cluster1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"http-hec","protocol":"TCP","port":8088,"targetPort":8088},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089},{"name":"tcp-s2s","protocol":"TCP","port":9997,"targetPort":9997}],"selector":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-cluster1-indexer"}},"status":{"loadBalancer":{}}}`) + test(SplunkIndexer, false, loadFixture(t, "splunk_indexer_multipart_service.json")) cr.Spec.ClusterManagerRef.Name = "" cr.Spec.ServiceTemplate.Spec.Type = "LoadBalancer" @@ -107,8 +107,8 @@ func TestGetSplunkService(t *testing.T) { cr.ObjectMeta.Labels = map[string]string{"one": "two"} cr.ObjectMeta.Annotations = map[string]string{"a": "b"} - test(SplunkSearchHead, false, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-search-head-service","namespace":"test","creationTimestamp":null,"labels":{"1":"2","app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","one":"two"},"annotations":{"a":"b"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089}],"selector":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"type":"LoadBalancer"},"status":{"loadBalancer":{}}}`) - test(SplunkSearchHead, true, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-search-head-headless","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","one":"two"},"annotations":{"a":"b"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089}],"selector":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"clusterIP":"None","type":"ClusterIP","publishNotReadyAddresses":true},"status":{"loadBalancer":{}}}`) + test(SplunkSearchHead, false, loadFixture(t, "splunk_search_head_service.json")) + test(SplunkSearchHead, true, loadFixture(t, "splunk_search_head_headless.json")) } func TestGetSplunkDefaults(t *testing.T) { @@ -129,7 +129,7 @@ func TestGetSplunkDefaults(t *testing.T) { configTester(t, "getSplunkDefaults()", f, want) } - test(`{"metadata":{"name":"splunk-stack1-indexer-defaults","namespace":"test","creationTimestamp":null},"data":{"default.yml":"defaults_string"}}`) + test(loadFixture(t, "splunk_defaults.json")) } func TestGetService(t *testing.T) { @@ -161,7 +161,7 @@ func TestGetService(t *testing.T) { configTester(t, "getSplunkService()", f, want) } - test(SplunkIndexer, `{"kind":"Service","apiVersion":"v1","metadata":{"name":"splunk-stack1-indexer-service","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"ports":[{"name":"user-defined","port":32000,"targetPort":6443},{"name":"http-splunkweb","protocol":"TCP","port":8000,"targetPort":8000},{"name":"http-hec","protocol":"TCP","port":8088,"targetPort":8088},{"name":"https-splunkd","protocol":"TCP","port":8089,"targetPort":8089},{"name":"tcp-s2s","protocol":"TCP","port":9997,"targetPort":9997}],"selector":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-stack1-indexer"}},"status":{"loadBalancer":{}}}`) + test(SplunkIndexer, loadFixture(t, "splunk_indexer_service_with_custom_port.json")) } func TestSetVolumeDefault(t *testing.T) { diff --git a/pkg/splunk/enterprise/indexercluster_test.go b/pkg/splunk/enterprise/indexercluster_test.go index 1f98f767d..8513972e0 100644 --- a/pkg/splunk/enterprise/indexercluster_test.go +++ b/pkg/splunk/enterprise/indexercluster_test.go @@ -485,7 +485,7 @@ func TestVerifyRFPeers(t *testing.T) { URL: "https://splunk-manager1-cluster-manager-service.test.svc.cluster.local:8089/services/cluster/config?count=0&output_mode=json", Status: 200, Err: nil, - Body: `{"links":{"_reload":"/services/cluster/config/_reload","_acl":"/services/cluster/config/_acl"},"origin":"https://localhost:8089/services/cluster/config","updated":"2020-10-28T21:37:07+00:00","generator":{"build":"152fb4b2bb96","version":"8.0.6"},"entry":[{"name":"config","id":"https://localhost:8089/services/cluster/config/config","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/cluster/config/config","list":"/services/cluster/config/config","_reload":"/services/cluster/config/config/_reload","edit":"/services/cluster/config/config","disable":"/services/cluster/config/config/disable"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"access_logging_for_heartbeats":false,"auto_rebalance_primaries":true,"buckets_to_summarize":"primaries","cluster_label":"idxc_label","cxn_timeout":60,"decommission_force_finish_idle_time":0,"decommission_force_timeout":180,"disabled":false,"eai:acl":null,"forwarderdata_rcv_port":0,"forwarderdata_use_ssl":false,"frozen_notifications_per_batch":10,"guid":"F643BA71-0D3C-4D63-A0BC-A1604AC928E3","heartbeat_period":18446744073709552000,"heartbeat_timeout":60,"master_uri":"https://127.0.0.1:8089","max_auto_service_interval":30,"max_fixup_time_ms":5000,"max_peer_build_load":2,"max_peer_rep_load":5,"max_peer_sum_rep_load":5,"max_peers_to_download_bundle":5,"max_primary_backups_per_service":10,"mode":"master","multisite":"false","notify_buckets_period":10,"notify_scan_min_period":10,"notify_scan_period":10,"percent_peers_to_restart":10,"ping_flag":true,"quiet_period":60,"rcv_timeout":60,"rebalance_primaries_execution_limit_ms":0,"rebalance_threshold":0.9,"register_forwarder_address":"","register_replication_address":"","register_search_address":"","remote_storage_upload_timeout":60,"rep_cxn_timeout":60,"rep_max_rcv_timeout":180,"rep_max_send_timeout":180,"rep_rcv_timeout":60,"rep_send_timeout":60,"replication_factor":3,"replication_port":null,"replication_use_ssl":false,"report_remote_storage_bucket_upload_to_targets":false,"reporting_delay_period":30,"restart_inactivity_timeout":600,"restart_timeout":60,"rolling_restart":"restart","search_factor":3,"search_files_retry_timeout":600,"secret":"********","send_timeout":60,"service_interval":0,"site":"default","site_by_site":true,"summary_replication":"false","use_batch_discard":"true","use_batch_mask_changes":"true","use_batch_remote_rep_changes":"false"}}],"paging":{"total":1,"perPage":10000000,"offset":0},"messages":[]}`, + Body: loadFixture(t, "service_stack1_indexer_service.json"), }, } @@ -497,7 +497,7 @@ func TestVerifyRFPeers(t *testing.T) { indexerClusterPodManagerReplicasTester(t, method, mockHandlers, 1 /*replicas*/, 3 /*desired replicas*/, enterpriseApi.PhaseReady, wantCalls, nil) // Now test for multi-site too - mockHandlers[0].Body = `{"links":{"_reload":"/services/cluster/config/_reload","_acl":"/services/cluster/config/_acl"},"origin":"https://localhost:8089/services/cluster/config","updated":"2020-10-28T21:37:07+00:00","generator":{"build":"152fb4b2bb96","version":"8.0.6"},"entry":[{"name":"config","id":"https://localhost:8089/services/cluster/config/config","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/cluster/config/config","list":"/services/cluster/config/config","_reload":"/services/cluster/config/config/_reload","edit":"/services/cluster/config/config","disable":"/services/cluster/config/config/disable"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"access_logging_for_heartbeats":false,"auto_rebalance_primaries":true,"buckets_to_summarize":"primaries","cluster_label":"idxc_label","cxn_timeout":60,"decommission_force_finish_idle_time":0,"decommission_force_timeout":180,"disabled":false,"eai:acl":null,"forwarderdata_rcv_port":0,"forwarderdata_use_ssl":false,"frozen_notifications_per_batch":10,"guid":"F643BA71-0D3C-4D63-A0BC-A1604AC928E3","heartbeat_period":18446744073709552000,"heartbeat_timeout":60,"master_uri":"https://127.0.0.1:8089","max_auto_service_interval":30,"max_fixup_time_ms":5000,"max_peer_build_load":2,"max_peer_rep_load":5,"max_peer_sum_rep_load":5,"max_peers_to_download_bundle":5,"max_primary_backups_per_service":10,"mode":"master","multisite":"true","notify_buckets_period":10,"notify_scan_min_period":10,"notify_scan_period":10,"percent_peers_to_restart":10,"ping_flag":true,"quiet_period":60,"rcv_timeout":60,"rebalance_primaries_execution_limit_ms":0,"rebalance_threshold":0.9,"register_forwarder_address":"","register_replication_address":"","register_search_address":"","remote_storage_upload_timeout":60,"rep_cxn_timeout":60,"rep_max_rcv_timeout":180,"rep_max_send_timeout":180,"rep_rcv_timeout":60,"rep_send_timeout":60,"replication_factor":3,"replication_port":null,"replication_use_ssl":false,"report_remote_storage_bucket_upload_to_targets":false,"reporting_delay_period":30,"restart_inactivity_timeout":600,"restart_timeout":60,"rolling_restart":"restart","search_factor":3,"search_files_retry_timeout":600,"secret":"********","send_timeout":60,"service_interval":0,"site":"site1","site_by_site":true,"site_replication_factor":"{ origin:2, total:2 }","site_search_factor":"{ origin:2, total:2 }","summary_replication":"false","use_batch_discard":"true","use_batch_mask_changes":"true","use_batch_remote_rep_changes":"false"}}],"paging":{"total":1,"perPage":10000000,"offset":0},"messages":[]}` + mockHandlers[0].Body = loadFixture(t, "service_stack1_indexer_headless.json") //test for multisite i.e. with site_replication_factor=origin:2,total:2(on ClusterManager) and replicas=2(on IndexerCluster) indexerClusterPodManagerReplicasTester(t, method, mockHandlers, 2 /*replicas*/, 2 /*desired replicas*/, enterpriseApi.PhaseReady, wantCalls, nil) @@ -563,7 +563,7 @@ func TestUpdateStatusInvalidResponse(t *testing.T) { t.Errorf("mgr.updateStatus() should have returned an error here") } - mockHandlers[0].Body = `{"links":{},"origin":"https://localhost:8089/services/cluster/manager/info","updated":"2020-03-18T01:04:53+00:00","generator":{"build":"a7f645ddaf91","version":"8.0.2"},"entry":[{"name":"master","id":"https://localhost:8089/services/cluster/manager/info/master","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/cluster/manager/info/master","list":"/services/cluster/manager/info/master"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"active_bundle":{"bundle_path":"/opt/splunk/var/run/splunk/cluster/remote-bundle/506c58d5aeda1dd6017889e3186e7337-1583870198.bundle","checksum":"14310A4AABD23E85BBD4559C4A3B59F8","timestamp":1583870198},"apply_bundle_status":{"invalid_bundle":{"bundle_path":"","bundle_validation_errors_on_master":[],"checksum":"","timestamp":0},"reload_bundle_issued":false,"status":"None"},"backup_and_restore_primaries":false,"controlled_rolling_restart_flag":false,"eai:acl":null,"indexing_ready_flag":true,"initialized_flag":true,"label":"splunk-stack1-cluster-manager-0","last_check_restart_bundle_result":false,"last_dry_run_bundle":{"bundle_path":"","checksum":"","timestamp":0},"last_validated_bundle":{"bundle_path":"/opt/splunk/var/run/splunk/cluster/remote-bundle/0af7c0e95f313f7be3b0cb1d878df9a1-1583948640.bundle","checksum":"14310A4AABD23E85BBD4559C4A3B59F8","is_valid_bundle":true,"timestamp":1583948640},"latest_bundle":{"bundle_path":"/opt/splunk/var/run/splunk/cluster/remote-bundle/506c58d5aeda1dd6017889e3186e7337-1583870198.bundle","checksum":"14310A4AABD23E85BBD4559C4A3B59F8","timestamp":1583870198},"maintenance_mode":false,"multisite":false,"previous_active_bundle":{"bundle_path":"","checksum":"","timestamp":0},"primaries_backup_status":"No on-going (or) completed primaries backup yet. Check back again in few minutes if you expect a backup.","quiet_period_flag":false,"rolling_restart_flag":false,"rolling_restart_or_upgrade":false,"service_ready_flag":true,"start_time":1583948636,"summary_replication":"false"}}],"paging":{"total":1,"perPage":30,"offset":0},"messages":[]}` + mockHandlers[0].Body = loadFixture(t, "service_stack1_indexer_with_port.json") mockHandler := spltest.MockHTTPHandler{ Method: "GET", @@ -867,7 +867,7 @@ func TestIndexerClusterPodManager(t *testing.T) { indexerClusterPodManagerUpdateTester(t, method, mockHandlers, 1, enterpriseApi.PhaseScalingDown, statefulSet, wantCalls, nil, statefulSet, pod) // test scale down => decommission pod - mockHandlers[1].Body = `{"entry":[{"name":"aa45bf46-7f46-47af-a760-590d5c606d10","content":{"status":"Up","label":"splunk-stack1-indexer-0"}},{"name":"D39B1729-E2C5-4273-B9B2-534DA7C2F866","content":{"status":"GracefulShutdown","label":"splunk-stack1-indexer-1"}}]}` + mockHandlers[1].Body = loadFixture(t, "configmap_indexer_smartstore.json") mockHandlers = append(mockHandlers, spltest.MockHTTPHandler{ Method: "POST", URL: "https://splunk-manager1-cluster-manager-service.test.svc.cluster.local:8089/services/cluster/manager/control/control/remove_peers?peers=D39B1729-E2C5-4273-B9B2-534DA7C2F866", @@ -1368,16 +1368,16 @@ func TestGetIndexerStatefulSet(t *testing.T) { } cr.Spec.Replicas = 0 - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_base.json")) cr.Spec.Replicas = 1 - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_base_1.json")) // Define additional service port in CR and verified 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-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_base_2.json")) // Block moving DefaultsURLApps to SPLUNK_DEFAULTS_URL for indexer cluster member cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_base_3.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -1388,7 +1388,7 @@ func TestGetIndexerStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -1397,12 +1397,12 @@ func TestGetIndexerStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"},"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-stack1-indexer-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_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_with_service_account_1.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-stack1-indexer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","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-stack1-indexer-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_CLUSTER_MASTER_URL","value":"splunk-manager1-cluster-manager-service"},{"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_indexer"},{"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-stack1-indexer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","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":"indexer","app.kubernetes.io/instance":"splunk-stack1-indexer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"indexer","app.kubernetes.io/part-of":"splunk-manager1-indexer","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-indexer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_indexer_with_service_account_2.json")) cr.Spec.ClusterManagerRef.Namespace = "other" if err := validateIndexerClusterSpec(ctx, c, &cr); err == nil { diff --git a/pkg/splunk/enterprise/licensemanager_test.go b/pkg/splunk/enterprise/licensemanager_test.go index fbba2dc2c..ae5afb98a 100644 --- a/pkg/splunk/enterprise/licensemanager_test.go +++ b/pkg/splunk/enterprise/licensemanager_test.go @@ -163,14 +163,14 @@ func TestGetLicenseManagerStatefulSet(t *testing.T) { configTester(t, "getLicenseManagerStatefulSet()", f, want) } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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_license_master"},{"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_base.json")) cr.Spec.LicenseURL = "/mnt/splunk.lic" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_base_1.json")) // Allow installing apps via DefaultsURLApps for License Manager cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -181,7 +181,7 @@ func TestGetLicenseManagerStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -190,12 +190,12 @@ func TestGetLicenseManagerStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_with_service_account_1.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-stack1-license-manager","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager","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"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-manager-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-manager"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager","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":"license-manager","app.kubernetes.io/instance":"splunk-stack1-license-manager","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-manager","app.kubernetes.io/part-of":"splunk-stack1-license-manager","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-manager-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_manager_with_service_account_2.json")) } func TestLicenseManagerSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/licensemaster_test.go b/pkg/splunk/enterprise/licensemaster_test.go index 5c366e52e..9044dff89 100644 --- a/pkg/splunk/enterprise/licensemaster_test.go +++ b/pkg/splunk/enterprise/licensemaster_test.go @@ -179,12 +179,12 @@ func TestGetLicenseMasterStatefulSet(t *testing.T) { configTester(t, "getLicenseMasterStatefulSet()", f, want) } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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_license_master"},{"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_base.json")) cr.Spec.LicenseURL = "/mnt/splunk.lic" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_base_1.json")) // Allow installing apps via DefaultsURLApps for Licence Manager cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ @@ -194,7 +194,7 @@ func TestGetLicenseMasterStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ { @@ -202,12 +202,12 @@ func TestGetLicenseMasterStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_with_service_account_1.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-stack1-license-master","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master","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"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-license-master-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"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/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_license_master"},{"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"},{"name":"SPLUNK_LICENSE_URI","value":"/mnt/splunk.lic"}],"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-stack1-license-master"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master","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":"license-master","app.kubernetes.io/instance":"splunk-stack1-license-master","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"license-master","app.kubernetes.io/part-of":"splunk-stack1-license-master","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-license-master-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_license_master_with_service_account_2.json")) } func TestLicenseMasterSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/monitoringconsole_test.go b/pkg/splunk/enterprise/monitoringconsole_test.go index 69546d848..3108c7d6a 100644 --- a/pkg/splunk/enterprise/monitoringconsole_test.go +++ b/pkg/splunk/enterprise/monitoringconsole_test.go @@ -1,30 +1,25 @@ // Copyright (c) 2018-2022 Splunk Inc. All rights reserved. - // // 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 +// 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 enterprise import ( "context" - "os" - "path/filepath" - "runtime/debug" - "testing" - "time" - enterpriseApi "github.com/splunk/splunk-operator/api/v4" - + splclient "github.com/splunk/splunk-operator/pkg/splunk/client" + splcommon "github.com/splunk/splunk-operator/pkg/splunk/common" + spltest "github.com/splunk/splunk-operator/pkg/splunk/test" + splutil "github.com/splunk/splunk-operator/pkg/splunk/util" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -32,13 +27,13 @@ import ( "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + "os" + "path/filepath" + "runtime/debug" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" - - splclient "github.com/splunk/splunk-operator/pkg/splunk/client" - splcommon "github.com/splunk/splunk-operator/pkg/splunk/common" - spltest "github.com/splunk/splunk-operator/pkg/splunk/test" - splutil "github.com/splunk/splunk-operator/pkg/splunk/util" + "testing" + "time" ) func init() { @@ -56,7 +51,6 @@ func init() { return fileLocation } } - func TestApplyMonitoringConsole(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") funcCalls := []spltest.MockFuncCall{ @@ -79,7 +73,6 @@ func TestApplyMonitoringConsole(t *testing.T) { {MetaName: "*v4.MonitoringConsole-test-stack1"}, {MetaName: "*v4.MonitoringConsole-test-stack1"}, } - updateFuncCalls := []spltest.MockFuncCall{ {MetaName: "*v1.Secret-test-splunk-test-secret"}, {MetaName: "*v1.Secret-test-splunk-test-secret"}, @@ -98,12 +91,10 @@ func TestApplyMonitoringConsole(t *testing.T) { {MetaName: "*v4.MonitoringConsole-test-stack1"}, {MetaName: "*v4.MonitoringConsole-test-stack1"}, } - labels := map[string]string{ "app.kubernetes.io/component": "versionedSecrets", "app.kubernetes.io/managed-by": "splunk-operator", } - listOpts := []client.ListOption{ client.InNamespace("test"), client.MatchingLabels(labels), @@ -111,15 +102,12 @@ func TestApplyMonitoringConsole(t *testing.T) { listOpts2 := []client.ListOption{ client.InNamespace("test"), } - listmockCall := []spltest.MockFuncCall{ {ListOpts: listOpts}, {ListOpts: listOpts2}, } - createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": {funcCalls[0], funcCalls[3], funcCalls[4], funcCalls[5], funcCalls[9], funcCalls[11], funcCalls[12], funcCalls[6]}, "Update": {funcCalls[0], funcCalls[12]}, "List": {listmockCall[0]}} updateCalls := map[string][]spltest.MockFuncCall{"Get": updateFuncCalls, "Update": {updateFuncCalls[5]}, "List": {listmockCall[0]}} - current := enterpriseApi.MonitoringConsole{ TypeMeta: metav1.TypeMeta{ Kind: "MonitoringConsole", @@ -136,7 +124,6 @@ func TestApplyMonitoringConsole(t *testing.T) { return err } spltest.ReconcileTesterWithoutRedundantCheck(t, "TestApplyMonitoringConsole", ¤t, revised, createCalls, updateCalls, reconcile, true) - // test deletion currentTime := metav1.NewTime(time.Now()) revised.ObjectMeta.DeletionTimestamp = ¤tTime @@ -147,37 +134,29 @@ func TestApplyMonitoringConsole(t *testing.T) { } splunkDeletionTester(t, revised, deleteFunc) } - func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") ctx := context.TODO() funcCalls := []spltest.MockFuncCall{ {MetaName: "*v1.ConfigMap-test-splunk-test-monitoring-console"}, } - env := []corev1.EnvVar{ {Name: "A", Value: "a"}, } - newURLsAdded := true monitoringConsoleRef := "test" reconcile := func(c *spltest.MockClient, cr interface{}) error { _, err := ApplyMonitoringConsoleEnvConfigMap(ctx, c, "test", "test", monitoringConsoleRef, env, newURLsAdded) return err } - //if monitoring-console env configMap doesn't exist, then create one createCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": funcCalls} updateCalls := map[string][]spltest.MockFuncCall{"Get": funcCalls} - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false) - //if configMap exists then update it createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - newURLsAdded = true - current := corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -185,15 +164,11 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { }, Data: map[string]string{"a": "b"}, } - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - //check for deletion createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - newURLsAdded = false - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -201,20 +176,14 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { }, Data: map[string]string{"a": "b"}, } - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - //no configMap exist and try to do deletion then just create a empty configMap createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Create": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -223,16 +192,12 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "a,b"}, } newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - env = []corev1.EnvVar{ {Name: "A", Value: "test-a"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -241,16 +206,12 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "test-a"}, } newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - env = []corev1.EnvVar{ {Name: "A", Value: "test-a,test-b"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -259,16 +220,12 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "test-a"}, } newURLsAdded = true - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - env = []corev1.EnvVar{ {Name: "A", Value: "test-a"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -277,16 +234,12 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "test-a,test-b"}, } newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - env = []corev1.EnvVar{ {Name: "A", Value: "test-b"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -295,16 +248,12 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "test-a,test-b"}, } newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls, "Update": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - env = []corev1.EnvVar{ {Name: "SPLUNK_MULTISITE_MASTER", Value: "test-a"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -313,13 +262,10 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"SPLUNK_MULTISITE_MASTER": "test-a", "SPLUNK_SITE": "abc"}, } newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - env = []corev1.EnvVar{ {Name: "A", Value: "test-a,test-b"}, } - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -327,18 +273,13 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { }, Data: map[string]string{"A": "test-a,test-b,test-c"}, } - newURLsAdded = false - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - env = []corev1.EnvVar{ {Name: "A", Value: "test-b"}, } - createCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} updateCalls = map[string][]spltest.MockFuncCall{"Get": funcCalls} - current = corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console", @@ -347,9 +288,7 @@ func TestApplyMonitoringConsoleEnvConfigMap(t *testing.T) { Data: map[string]string{"A": "test-a,test-b"}, } newURLsAdded = true - spltest.ReconcileTester(t, "TestApplyMonitoringConsoleEnvConfigMap", "test", "test", createCalls, updateCalls, reconcile, false, ¤t) - } func TestAddURLsConfigMapMultipleEnvVars(t *testing.T) { @@ -473,7 +412,6 @@ func TestAddURLsConfigMapMultipleEnvVars(t *testing.T) { func TestGetMonitoringConsoleStatefulSet(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") - ctx := context.TODO() cr := enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ @@ -481,13 +419,11 @@ func TestGetMonitoringConsoleStatefulSet(t *testing.T) { Namespace: "test", }, } - c := spltest.NewMockClient() _, err := splutil.ApplyNamespaceScopedSecretObject(ctx, c, "test") if err != nil { t.Errorf("Failed to create namespace scoped object") } - test := func(want string) { f := func() (interface{}, error) { if err := validateMonitoringConsoleSpec(ctx, c, &cr); err != nil { @@ -497,16 +433,12 @@ func TestGetMonitoringConsoleStatefulSet(t *testing.T) { } configTester(t, "getMonitoringConsoleStatefulSet()", f, want) } - - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","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-stack1-monitoring-console-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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"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_monitor"},{"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_with_defaults.json")) cr.Spec.EtcVolumeStorageConfig.EphemeralStorage = true cr.Spec.VarVolumeStorageConfig.EphemeralStorage = true - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"mnt-splunk-etc","emptyDir":{}},{"name":"mnt-splunk-var","emptyDir":{}},{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"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_monitor"},{"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":"mnt-splunk-etc","mountPath":"/opt/splunk/etc"},{"name":"mnt-splunk-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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_with_apps.json")) cr.Spec.EtcVolumeStorageConfig.EphemeralStorage = false cr.Spec.VarVolumeStorageConfig.EphemeralStorage = false - cr.Spec.ClusterManagerRef.Name = "stack2" cr.Spec.EtcVolumeStorageConfig.StorageClassName = "gp2" cr.Spec.VarVolumeStorageConfig.StorageClassName = "gp2" @@ -516,11 +448,9 @@ func TestGetMonitoringConsoleStatefulSet(t *testing.T) { cr.Spec.Volumes = []corev1.Volume{ {Name: "defaults"}, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-monitoring-console-defaults","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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_monitor"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_with_service_account_2.json")) cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-monitoring-console-defaults","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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_monitor"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_base.json")) // Create a serviceaccount current := corev1.ServiceAccount{ ObjectMeta: metav1.ObjectMeta{ @@ -530,8 +460,7 @@ func TestGetMonitoringConsoleStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-monitoring-console-defaults","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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_monitor"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_base_1.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ { @@ -539,18 +468,16 @@ func TestGetMonitoringConsoleStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"},"annotations":{"monitoringConsoleConfigRev":"","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-monitoring-console-defaults","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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_monitor"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) - + test(loadFixture(t, "statefulset_stack1_monitoring_console_with_service_account.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-stack1-monitoring-console","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"annotations":{"monitoringConsoleConfigRev":"","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-monitoring-console-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-monitoring-console-defaults","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"}],"envFrom":[{"configMapRef":{"name":"splunk-stack1-monitoring-console"}}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_monitor"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-monitoring-console"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"monitoring-console","app.kubernetes.io/instance":"splunk-stack1-monitoring-console","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"monitoring-console","app.kubernetes.io/part-of":"splunk-stack1-monitoring-console","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-monitoring-console-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_monitoring_console_with_service_account_1.json")) } func TestMonitoringConsoleSpecNotCreatedWithoutGeneralTerms(t *testing.T) { // Unset the SPLUNK_GENERAL_TERMS environment variable os.Unsetenv("SPLUNK_GENERAL_TERMS") ctx := context.TODO() - // Create a mock monitoring console CR mc := enterpriseApi.MonitoringConsole{ TypeMeta: metav1.TypeMeta{ @@ -561,13 +488,10 @@ func TestMonitoringConsoleSpecNotCreatedWithoutGeneralTerms(t *testing.T) { Namespace: "test", }, } - // Create a mock client c := spltest.NewMockClient() - // Attempt to apply the monitoring console spec _, err := ApplyMonitoringConsole(ctx, c, &mc) - // Assert that an error is returned if err == nil { t.Errorf("Expected error when SPLUNK_GENERAL_TERMS is not set, but got none") @@ -577,7 +501,6 @@ func TestMonitoringConsoleSpecNotCreatedWithoutGeneralTerms(t *testing.T) { } func TestAppFrameworkApplyMonitoringConsoleShouldNotFail(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") - ctx := context.TODO() cr := enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ @@ -612,34 +535,27 @@ func TestAppFrameworkApplyMonitoringConsoleShouldNotFail(t *testing.T) { }, }, } - client := spltest.NewMockClient() - // Create namespace scoped secret _, err := splutil.ApplyNamespaceScopedSecretObject(ctx, client, "test") if err != nil { t.Error(err.Error()) } - // Create S3 secret s3Secret := spltest.GetMockS3SecretKeys("s3-secret") client.AddObject(&s3Secret) configmap := spltest.GetMockPerCRConfigMap("splunk-monitoring-console-monitoringConsole-configmap") client.AddObject(&configmap) - // to pass the validation stage, add the directory to download apps _ = os.MkdirAll(splcommon.AppDownloadVolume, 0755) defer os.RemoveAll(splcommon.AppDownloadVolume) - _, err = ApplyMonitoringConsole(ctx, client, &cr) if err != nil { t.Errorf("ApplyMonitoringConsole should be successful") } } - func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldNotFail(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") - ctx := context.TODO() cr := enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ @@ -690,30 +606,22 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldNotFail(t *testing.T) { }, }, } - client := spltest.NewMockClient() - // Create S3 secret s3Secret := spltest.GetMockS3SecretKeys("s3-secret") - client.AddObject(&s3Secret) - // Create namespace scoped secret _, err := splutil.ApplyNamespaceScopedSecretObject(ctx, client, "test") if err != nil { t.Error(err.Error()) } - splclient.RegisterRemoteDataClient(ctx, "aws") - Etags := []string{"cc707187b036405f095a8ebb43a782c1", "5055a61b3d1b667a4c3279a381a2e7ae", "19779168370b97d8654424e6c9446dd9"} Keys := []string{"admin_app.tgz", "security_app.tgz", "authentication_app.tgz"} Sizes := []int64{10, 20, 30} StorageClass := "STANDARD" randomTime := time.Date(2021, time.May, 1, 23, 23, 0, 0, time.UTC) - mockAwsHandler := spltest.MockAWSS3Handler{} - mockAwsObjects := []spltest.MockAWSS3Client{ { Objects: []*spltest.MockRemoteDataObject{ @@ -749,25 +657,19 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldNotFail(t *testing.T) { }, }, } - appFrameworkRef := cr.Spec.AppFrameworkConfig - mockAwsHandler.AddObjects(appFrameworkRef, mockAwsObjects...) - var vol enterpriseApi.VolumeSpec var allSuccess bool = true for index, appSource := range appFrameworkRef.AppSources { - vol, err = splclient.GetAppSrcVolume(ctx, appSource, &appFrameworkRef) if err != nil { allSuccess = false continue } - // Update the GetRemoteDataClient with our mock call which initializes mock AWS client getClientWrapper := splclient.RemoteDataClientsMap[vol.Provider] getClientWrapper.SetRemoteDataClientFuncPtr(ctx, vol.Provider, splclient.NewMockAWSS3Client) - remoteDataClientMgr := &RemoteDataClientManager{client: client, cr: &cr, appFrameworkRef: &cr.Spec.AppFrameworkConfig, vol: &vol, @@ -782,37 +684,30 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldNotFail(t *testing.T) { return c, err }, } - RemoteDataListResponse, err := remoteDataClientMgr.GetAppsList(ctx) if err != nil { allSuccess = false continue } - var mockResponse spltest.MockRemoteDataClient mockResponse, err = splclient.ConvertRemoteDataListResponse(ctx, RemoteDataListResponse) if err != nil { allSuccess = false continue } - if mockAwsHandler.GotSourceAppListResponseMap == nil { mockAwsHandler.GotSourceAppListResponseMap = make(map[string]spltest.MockAWSS3Client) } - mockAwsHandler.GotSourceAppListResponseMap[appSource.Name] = spltest.MockAWSS3Client(mockResponse) } - if allSuccess == false { t.Errorf("Unable to get apps list for all the app sources") } method := "GetAppsList" mockAwsHandler.CheckAWSRemoteDataListResponse(t, method) } - func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") - ctx := context.TODO() cr := enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ @@ -840,25 +735,19 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { }, }, } - client := spltest.NewMockClient() - // Create namespace scoped secret _, err := splutil.ApplyNamespaceScopedSecretObject(ctx, client, "test") if err != nil { t.Error(err.Error()) } - splclient.RegisterRemoteDataClient(ctx, "aws") - Etags := []string{"cc707187b036405f095a8ebb43a782c1"} Keys := []string{"admin_app.tgz"} Sizes := []int64{10} StorageClass := "STANDARD" randomTime := time.Date(2021, time.May, 1, 23, 23, 0, 0, time.UTC) - mockAwsHandler := spltest.MockAWSS3Handler{} - mockAwsObjects := []spltest.MockAWSS3Client{ { Objects: []*spltest.MockRemoteDataObject{ @@ -872,23 +761,17 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { }, }, } - appFrameworkRef := cr.Spec.AppFrameworkConfig - mockAwsHandler.AddObjects(appFrameworkRef, mockAwsObjects...) - var vol enterpriseApi.VolumeSpec - appSource := appFrameworkRef.AppSources[0] vol, err = splclient.GetAppSrcVolume(ctx, appSource, &appFrameworkRef) if err != nil { t.Errorf("Unable to get Volume due to error=%s", err) } - // Update the GetRemoteDataClient with our mock call which initializes mock AWS client getClientWrapper := splclient.RemoteDataClientsMap[vol.Provider] getClientWrapper.SetRemoteDataClientFuncPtr(ctx, vol.Provider, splclient.NewMockAWSS3Client) - remoteDataClientMgr := &RemoteDataClientManager{ client: client, cr: &cr, @@ -907,12 +790,10 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { return c, err }, } - _, err = remoteDataClientMgr.GetAppsList(ctx) if err == nil { t.Errorf("GetAppsList should have returned error as there is no S3 secret provided") } - // Create empty S3 secret s3Secret := corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -921,44 +802,36 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { }, Data: map[string][]byte{}, } - client.AddObject(&s3Secret) - _, err = remoteDataClientMgr.GetAppsList(ctx) if err == nil { t.Errorf("GetAppsList should have returned error as S3 secret has empty keys") } - s3AccessKey := []byte{'1'} s3Secret.Data = map[string][]byte{"s3_access_key": s3AccessKey} _, err = remoteDataClientMgr.GetAppsList(ctx) if err == nil { t.Errorf("GetAppsList should have returned error as S3 secret has empty s3_secret_key") } - s3SecretKey := []byte{'2'} s3Secret.Data = map[string][]byte{"s3_secret_key": s3SecretKey} _, err = remoteDataClientMgr.GetAppsList(ctx) if err == nil { t.Errorf("GetAppsList should have returned error as S3 secret has empty s3_access_key") } - // Create S3 secret s3Secret = spltest.GetMockS3SecretKeys("s3-secret") - // This should return an error as we have initialized initFn for remoteDataClientMgr // to return a nil client. _, err = remoteDataClientMgr.GetAppsList(ctx) if err == nil { t.Errorf("GetAppsList should have returned error as we could not get the S3 client") } - remoteDataClientMgr.initFn = func(ctx context.Context, region, accessKeyID, secretAccessKey string) interface{} { // To test the error scenario, do no set the Objects member yet cl := spltest.MockAWSS3Client{} return cl } - remoteDataClientResponse, err := remoteDataClientMgr.GetAppsList(ctx) if err != nil { t.Errorf("GetAppsList should not have returned error since empty appSources are allowed.") @@ -967,15 +840,12 @@ func TestMonitoringConsoleGetAppsListForAWSS3ClientShouldFail(t *testing.T) { t.Errorf("GetAppsList should return an empty response since we have empty objects in MockAWSS3Client") } } - func TestMonitoringConsoleWithReadyState(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") - sch := pkgruntime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(sch)) utilruntime.Must(corev1.AddToScheme(sch)) utilruntime.Must(enterpriseApi.AddToScheme(sch)) - builder := fake.NewClientBuilder(). WithScheme(sch). WithStatusSubresource(&enterpriseApi.LicenseManager{}). @@ -986,7 +856,6 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { WithStatusSubresource(&enterpriseApi.SearchHeadCluster{}) c := builder.Build() ctx := context.TODO() - // create monitoringconsole custom resource monitoringconsole := &enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ @@ -1002,7 +871,6 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { }, }, } - replicas := int32(1) statefulset := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ @@ -1030,29 +898,23 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { Replicas: &replicas, }, } - service := &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "splunk-test-monitoring-console-headless", Namespace: "default", }, } - // simulate service c.Create(ctx, service) - // simulate create stateful set c.Create(ctx, statefulset) - // simulate create clustermanager instance before reconcilation c.Create(ctx, monitoringconsole) - _, err := ApplyMonitoringConsole(ctx, c, monitoringconsole) if err != nil { t.Errorf("Unexpected error while running reconciliation for indexer cluster %v", err) debug.PrintStack() } - namespacedName := types.NamespacedName{ Name: monitoringconsole.Name, Namespace: monitoringconsole.Namespace, @@ -1080,20 +942,17 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { t.Errorf("Unexpected error while running reconciliation for cluster master with app framework %v", err) debug.PrintStack() } - err = c.Get(ctx, namespacedName, monitoringconsole) if err != nil { t.Errorf("Unexpected get monitoring console %v", err) debug.PrintStack() } - // call reconciliation _, err = ApplyMonitoringConsole(ctx, c, monitoringconsole) if err != nil { t.Errorf("Unexpected error while running reconciliation for monitoring console with app framework %v", err) debug.PrintStack() } - // create pod stpod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -1121,7 +980,6 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { t.Errorf("Unexpected create pod failed %v", err) debug.PrintStack() } - // update statefulset stpod.Status.Phase = corev1.PodRunning stpod.Status.ContainerStatuses = []corev1.ContainerStatus{ @@ -1136,7 +994,6 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { t.Errorf("Unexpected update statefulset %v", err) debug.PrintStack() } - stNamespacedName := types.NamespacedName{ Name: "splunk-test-monitoring-console", Namespace: "default", @@ -1154,13 +1011,11 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { t.Errorf("Unexpected update statefulset %v", err) debug.PrintStack() } - err = c.Get(ctx, namespacedName, monitoringconsole) if err != nil { t.Errorf("Unexpected get monitoring console %v", err) debug.PrintStack() } - // call reconciliation _, err = ApplyMonitoringConsole(ctx, c, monitoringconsole) if err != nil { @@ -1168,7 +1023,6 @@ func TestMonitoringConsoleWithReadyState(t *testing.T) { debug.PrintStack() } } - func TestApplyMonitoringConsoleDeletion(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") ctx := context.TODO() @@ -1217,27 +1071,21 @@ func TestApplyMonitoringConsoleDeletion(t *testing.T) { }, }, } - c := spltest.NewMockClient() - // Create S3 secret s3Secret := spltest.GetMockS3SecretKeys("s3-secret") - c.AddObject(&s3Secret) configmap := spltest.GetMockPerCRConfigMap("splunk-monitoring-console-stack1-configmap") c.AddObject(&configmap) - // Create namespace scoped secret _, err := splutil.ApplyNamespaceScopedSecretObject(ctx, c, "test") if err != nil { t.Error(err.Error()) } - // test deletion currentTime := metav1.NewTime(time.Now()) mc.ObjectMeta.DeletionTimestamp = ¤tTime mc.ObjectMeta.Finalizers = []string{"enterprise.splunk.com/delete-pvc"} - pvclist := corev1.PersistentVolumeClaimList{ Items: []corev1.PersistentVolumeClaim{ { @@ -1249,57 +1097,44 @@ func TestApplyMonitoringConsoleDeletion(t *testing.T) { }, } c.ListObj = &pvclist - // to pass the validation stage, add the directory to download apps err = os.MkdirAll(splcommon.AppDownloadVolume, 0755) defer os.RemoveAll(splcommon.AppDownloadVolume) - if err != nil { t.Errorf("Unable to create download directory for apps :%s", splcommon.AppDownloadVolume) } - _, err = ApplyMonitoringConsole(ctx, c, &mc) if err != nil { t.Errorf("ApplyMonitoringConsole should not have returned error here.") } } - func TestGetMonitoringConsoleList(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") ctx := context.TODO() mc := enterpriseApi.MonitoringConsole{} - listOpts := []client.ListOption{ client.InNamespace("test"), } - client := spltest.NewMockClient() - mcList := &enterpriseApi.MonitoringConsoleList{} mcList.Items = append(mcList.Items, mc) - client.ListObj = mcList - objectList, err := getMonitoringConsoleList(ctx, client, &mc, listOpts) if err != nil { t.Errorf("getNumOfObjects should not have returned error=%v", err) } - numOfObjects := len(objectList.Items) if numOfObjects != 1 { t.Errorf("Got wrong number of IndexerCluster objects. Expected=%d, Got=%d", 1, numOfObjects) } } - func TestChangeMonitoringConsoleAnnotations(t *testing.T) { os.Setenv("SPLUNK_GENERAL_TERMS", "--accept-sgt-current-at-splunk-com") ctx := context.TODO() - sch := pkgruntime.NewScheme() utilruntime.Must(clientgoscheme.AddToScheme(sch)) utilruntime.Must(corev1.AddToScheme(sch)) utilruntime.Must(enterpriseApi.AddToScheme(sch)) - builder := fake.NewClientBuilder(). WithScheme(sch). WithStatusSubresource(&enterpriseApi.LicenseManager{}). @@ -1310,7 +1145,6 @@ func TestChangeMonitoringConsoleAnnotations(t *testing.T) { WithStatusSubresource(&enterpriseApi.SearchHeadCluster{}) client := builder.Build() utilruntime.Must(enterpriseApi.AddToScheme(clientgoscheme.Scheme)) - // define CM and MC cm := &enterpriseApi.ClusterManager{ ObjectMeta: metav1.ObjectMeta{ @@ -1326,7 +1160,6 @@ func TestChangeMonitoringConsoleAnnotations(t *testing.T) { }, }, } - mc := &enterpriseApi.MonitoringConsole{ ObjectMeta: metav1.ObjectMeta{ Name: "test", @@ -1345,7 +1178,6 @@ func TestChangeMonitoringConsoleAnnotations(t *testing.T) { }, } cm.Spec.Image = "splunk/splunk:latest" - // Create the instances client.Create(ctx, cm) _, err := ApplyClusterManager(ctx, client, cm) @@ -1371,7 +1203,6 @@ func TestChangeMonitoringConsoleAnnotations(t *testing.T) { if err != nil { t.Errorf("applyMonitoringConsole should not have returned error; err=%v", err) } - err = changeMonitoringConsoleAnnotations(ctx, client, cm) if err != nil { t.Errorf("changeMonitoringConsoleAnnotations should not have returned error=%v", err) @@ -1385,7 +1216,6 @@ func TestChangeMonitoringConsoleAnnotations(t *testing.T) { if err != nil { t.Errorf("changeMonitoringConsoleAnnotations should not have returned error=%v", err) } - annotations := monitoringConsole.GetAnnotations() if annotations["splunk/image-tag"] != cm.Spec.Image { t.Errorf("changeMonitoringConsoleAnnotations should have set the checkUpdateImage annotation field to the current image") diff --git a/pkg/splunk/enterprise/searchheadcluster_test.go b/pkg/splunk/enterprise/searchheadcluster_test.go index 239c7fc8e..68118bf67 100644 --- a/pkg/splunk/enterprise/searchheadcluster_test.go +++ b/pkg/splunk/enterprise/searchheadcluster_test.go @@ -291,13 +291,13 @@ func TestSearchHeadClusterPodManager(t *testing.T) { URL: "https://splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local:8089/services/shcluster/member/info?count=0&output_mode=json", Status: 200, Err: nil, - Body: `{"links":{},"origin":"https://localhost:8089/services/shcluster/member/info","updated":"2020-03-15T16:30:38+00:00","generator":{"build":"a7f645ddaf91","version":"8.0.2"},"entry":[{"name":"member","id":"https://localhost:8089/services/shcluster/member/info/member","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/shcluster/member/info/member","list":"/services/shcluster/member/info/member"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"active_historical_search_count":0,"active_realtime_search_count":0,"adhoc_searchhead":false,"eai:acl":null,"is_registered":true,"last_heartbeat_attempt":1584289836,"maintenance_mode":false,"no_artifact_replications":false,"peer_load_stats_gla_15m":0,"peer_load_stats_gla_1m":0,"peer_load_stats_gla_5m":0,"peer_load_stats_max_runtime":0,"peer_load_stats_num_autosummary":0,"peer_load_stats_num_historical":0,"peer_load_stats_num_realtime":0,"peer_load_stats_num_running":0,"peer_load_stats_total_runtime":0,"restart_state":"NoRestart","status":"Up"}}],"paging":{"total":1,"perPage":30,"offset":0},"messages":[]}`, + Body: loadFixture(t, "shc_member_info_response.json"), }, { Method: "GET", URL: "https://splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local:8089/services/shcluster/captain/info?count=0&output_mode=json", Status: 200, Err: nil, - Body: `{"links":{},"origin":"https://localhost:8089/services/shcluster/captain/info","updated":"2020-03-15T16:36:42+00:00","generator":{"build":"a7f645ddaf91","version":"8.0.2"},"entry":[{"name":"captain","id":"https://localhost:8089/services/shcluster/captain/info/captain","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/shcluster/captain/info/captain","list":"/services/shcluster/captain/info/captain"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"eai:acl":null,"elected_captain":1584139352,"id":"A9D5FCCF-EB93-4E0A-93E1-45B56483EA7A","initialized_flag":true,"label":"splunk-s2-search-head-0","maintenance_mode":false,"mgmt_uri":"https://splunk-s2-search-head-0.splunk-s2-search-head-headless.splunk.svc.cluster.local:8089","min_peers_joined_flag":true,"peer_scheme_host_port":"https://splunk-s2-search-head-0.splunk-s2-search-head-headless.splunk.svc.cluster.local:8089","rolling_restart_flag":false,"service_ready_flag":true,"start_time":1584139291}}],"paging":{"total":1,"perPage":30,"offset":0},"messages":[]}`, + Body: loadFixture(t, "shc_captain_info_response.json"), }, } @@ -373,7 +373,7 @@ func TestSearchHeadClusterPodManager(t *testing.T) { URL: "https://splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local:8089/services/shcluster/member/info?count=0&output_mode=json", Status: 200, Err: nil, - Body: `{"links":{},"origin":"https://localhost:8089/services/shcluster/member/info","updated":"2020-03-15T16:30:38+00:00","generator":{"build":"a7f645ddaf91","version":"8.0.2"},"entry":[{"name":"member","id":"https://localhost:8089/services/shcluster/member/info/member","updated":"1970-01-01T00:00:00+00:00","links":{"alternate":"/services/shcluster/member/info/member","list":"/services/shcluster/member/info/member"},"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]},"removable":false,"sharing":"system"},"content":{"active_historical_search_count":0,"active_realtime_search_count":0,"adhoc_searchhead":false,"eai:acl":null,"is_registered":true,"last_heartbeat_attempt":1584289836,"maintenance_mode":false,"no_artifact_replications":false,"peer_load_stats_gla_15m":0,"peer_load_stats_gla_1m":0,"peer_load_stats_gla_5m":0,"peer_load_stats_max_runtime":0,"peer_load_stats_num_autosummary":0,"peer_load_stats_num_historical":0,"peer_load_stats_num_realtime":0,"peer_load_stats_num_running":0,"peer_load_stats_total_runtime":0,"restart_state":"NoRestart","status":"ManualDetention"}}],"paging":{"total":1,"perPage":30,"offset":0},"messages":[]}`, + Body: loadFixture(t, "shc_member_remove_response.json"), } mockHandlers = append(mockHandlers, spltest.MockHTTPHandler{ Method: "POST", @@ -688,25 +688,25 @@ func TestGetSearchHeadStatefulSet(t *testing.T) { } cr.Spec.Replicas = 3 - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":3,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base.json")) cr.Spec.Replicas = 4 - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":4,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base_1.json")) cr.Spec.Replicas = 5 cr.Spec.ClusterManagerRef.Name = "stack1" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":5,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base_2.json")) cr.Spec.Replicas = 6 cr.Spec.ClusterManagerRef.Namespace = "test2" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base_3.json")) cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base_4.json")) // Define additional service port in CR and verified the statefulset has the new port - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_base_5.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -717,7 +717,7 @@ func TestGetSearchHeadStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -726,12 +726,12 @@ func TestGetSearchHeadStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_with_service_account_1.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-stack1-search-head","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":6,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","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"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-search-head-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_DEPLOYER_URL","value":"splunk-stack1-deployer-service"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack1-cluster-manager-service.test2.svc.cluster.local"},{"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_search_head"},{"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-stack1-search-head"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","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":"search-head","app.kubernetes.io/instance":"splunk-stack1-search-head","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"search-head","app.kubernetes.io/part-of":"splunk-stack1-search-head","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-search-head-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_search_head_with_service_account_2.json")) } func TestGetDeployerStatefulSet(t *testing.T) { @@ -761,11 +761,11 @@ func TestGetDeployerStatefulSet(t *testing.T) { } cr.Spec.Replicas = 3 - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-deployer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-deployer-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"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_deployer"},{"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-stack1-deployer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-deployer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_deployer_base.json")) // Allow installation of apps via DefaultsURLApps on the SHCDeployer cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-deployer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-deployer-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_deployer"},{"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-stack1-deployer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-deployer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_deployer_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -777,7 +777,7 @@ func TestGetDeployerStatefulSet(t *testing.T) { _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-deployer","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000"}},"spec":{"volumes":[{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-deployer-secret-v1","defaultMode":420}}],"containers":[{"name":"splunk","image":"splunk/splunk","ports":[{"name":"http-splunkweb","containerPort":8000,"protocol":"TCP"},{"name":"https-splunkd","containerPort":8089,"protocol":"TCP"}],"env":[{"name":"SPLUNK_SEARCH_HEAD_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_SEARCH_HEAD_CAPTAIN_URL","value":"splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_deployer"},{"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-stack1-deployer"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"search-head","app.kubernetes.io/instance":"splunk-stack1-deployer","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"deployer","app.kubernetes.io/part-of":"splunk-stack1-search-head"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-deployer-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_deployer_with_service_account.json")) } func TestSearchHeadSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/standalone_test.go b/pkg/splunk/enterprise/standalone_test.go index 1e48bf85d..acdb07515 100644 --- a/pkg/splunk/enterprise/standalone_test.go +++ b/pkg/splunk/enterprise/standalone_test.go @@ -352,11 +352,11 @@ func TestGetStandaloneStatefulSet(t *testing.T) { } configTester(t, "getStandaloneStatefulSet()", f, want) } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"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-stack1-standalone-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"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}}},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}}},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_base.json")) cr.Spec.EtcVolumeStorageConfig.EphemeralStorage = true cr.Spec.VarVolumeStorageConfig.EphemeralStorage = true - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"annotations":{"traffic.sidecar.istio.io/excludeOutboundPorts":"8089,8191,9997","traffic.sidecar.istio.io/includeInboundPorts":"8000,8088"}},"spec":{"volumes":[{"name":"mnt-splunk-etc","emptyDir":{}},{"name":"mnt-splunk-var","emptyDir":{}},{"name":"splunk-test-probe-configmap","configMap":{"name":"splunk-test-probe-configmap","defaultMode":365}},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-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"}],"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":"mnt-splunk-etc","mountPath":"/opt/splunk/etc"},{"name":"mnt-splunk-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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"default-scheduler"}},"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_base_1.json")) cr.Spec.EtcVolumeStorageConfig.EphemeralStorage = false cr.Spec.VarVolumeStorageConfig.EphemeralStorage = false @@ -370,10 +370,10 @@ func TestGetStandaloneStatefulSet(t *testing.T) { cr.Spec.Volumes = []corev1.Volume{ {Name: "defaults"}, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-standalone-defaults","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"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_search_head"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_with_defaults.json")) cr.Spec.DefaultsURLApps = "/mnt/apps/apps.yml" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-standalone-defaults","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"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_search_head"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_with_apps.json")) // Create a serviceaccount current := corev1.ServiceAccount{ @@ -384,7 +384,7 @@ func TestGetStandaloneStatefulSet(t *testing.T) { } _ = splutil.CreateResource(ctx, c, ¤t) cr.Spec.ServiceAccount = "defaults" - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-standalone-defaults","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"}],"env":[{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_search_head"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_with_service_account.json")) // Add extraEnv cr.Spec.CommonSplunkSpec.ExtraEnv = []corev1.EnvVar{ @@ -393,12 +393,12 @@ func TestGetStandaloneStatefulSet(t *testing.T) { Value: "test_value", }, } - test(`{"kind":"StatefulSet","apiVersion":"apps/v1","metadata":{"name":"splunk-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"},"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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-standalone-defaults","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"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_search_head"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_with_service_account_1.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-stack1-standalone","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone","app.kubernetes.io/test-extra-label":"test-extra-label-value"},"ownerReferences":[{"apiVersion":"","kind":"","name":"stack1","uid":"","controller":true}]},"spec":{"replicas":1,"selector":{"matchLabels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone"}},"template":{"metadata":{"creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone","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":"defaults"},{"name":"mnt-splunk-secrets","secret":{"secretName":"splunk-stack1-standalone-secret-v1","defaultMode":420}},{"name":"mnt-splunk-defaults","configMap":{"name":"splunk-stack1-standalone-defaults","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"}],"env":[{"name":"TEST_ENV_VAR","value":"test_value"},{"name":"SPLUNK_CLUSTER_MASTER_URL","value":"splunk-stack2-cluster-manager-service"},{"name":"SPLUNK_HOME","value":"/opt/splunk"},{"name":"SPLUNK_START_ARGS","value":"--accept-license"},{"name":"SPLUNK_DEFAULTS_URL","value":"/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml"},{"name":"SPLUNK_HOME_OWNERSHIP_ENFORCEMENT","value":"false"},{"name":"SPLUNK_ROLE","value":"splunk_search_head"},{"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":"defaults","mountPath":"/mnt/defaults"},{"name":"mnt-splunk-secrets","mountPath":"/mnt/splunk-secrets"},{"name":"mnt-splunk-defaults","mountPath":"/mnt/splunk-defaults"}],"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-stack1-standalone"]}]},"topologyKey":"kubernetes.io/hostname"}}]}},"schedulerName":"custom-scheduler"}},"volumeClaimTemplates":[{"metadata":{"name":"pvc-etc","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"storageClassName":"gp2"},"status":{}},{"metadata":{"name":"pvc-var","namespace":"test","creationTimestamp":null,"labels":{"app.kubernetes.io/component":"standalone","app.kubernetes.io/instance":"splunk-stack1-standalone","app.kubernetes.io/managed-by":"splunk-operator","app.kubernetes.io/name":"standalone","app.kubernetes.io/part-of":"splunk-stack1-standalone","app.kubernetes.io/test-extra-label":"test-extra-label-value"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"100Gi"}},"storageClassName":"gp2"},"status":{}}],"serviceName":"splunk-stack1-standalone-headless","podManagementPolicy":"Parallel","updateStrategy":{"type":"OnDelete"}},"status":{"replicas":0,"availableReplicas":0}}`) + test(loadFixture(t, "statefulset_stack1_standalone_with_service_account_2.json")) } func TestStandaloneSpecNotCreatedWithoutGeneralTerms(t *testing.T) { diff --git a/pkg/splunk/enterprise/testdata/fixtures/configmap_indexer_smartstore.json b/pkg/splunk/enterprise/testdata/fixtures/configmap_indexer_smartstore.json new file mode 100644 index 000000000..b5703da2a --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/configmap_indexer_smartstore.json @@ -0,0 +1,18 @@ +{ + "entry": [ + { + "name": "aa45bf46-7f46-47af-a760-590d5c606d10", + "content": { + "status": "Up", + "label": "splunk-stack1-indexer-0" + } + }, + { + "name": "D39B1729-E2C5-4273-B9B2-534DA7C2F866", + "content": { + "status": "GracefulShutdown", + "label": "splunk-stack1-indexer-1" + } + } + ] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/configmap_smartstore_volumes.json b/pkg/splunk/enterprise/testdata/fixtures/configmap_smartstore_volumes.json new file mode 100644 index 000000000..351bd62c9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/configmap_smartstore_volumes.json @@ -0,0 +1,21 @@ +{ + "metadata": { + "name": "splunk-idxCluster--smartstore", + "namespace": "test", + "creationTimestamp": null, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "idxCluster", + "uid": "", + "controller": true + } + ] + }, + "data": { + "conftoken": "1601945361", + "indexes.conf": "[default]\nrepFactor = auto\nmaxDataSize = auto\nhomePath = $SPLUNK_DB/$_index_name/db\ncoldPath = $SPLUNK_DB/$_index_name/colddb\nthawedPath = $SPLUNK_DB/$_index_name/thaweddb\n \n[volume:msos_s2s3_vol]\nstorageType = remote\npath = s3://testbucket-rs-london\nremote.s3.access_key = abcdJDckRkxhMEdmSk5FekFRRzBFOXV6bGNldzJSWE9IenhVUy80aa\nremote.s3.secret_key = g4NVp0a29PTzlPdGczWk1vekVUcVBSa0o4NkhBWWMvR1NadDV4YVEy\nremote.s3.endpoint = https://s3-eu-west-2.amazonaws.com\nremote.s3.auth_region = \n \n[salesdata1]\nremotePath = volume:msos_s2s3_vol/remotepath1\n\n[salesdata2]\nremotePath = volume:msos_s2s3_vol/remotepath2\n\n[salesdata3]\nremotePath = volume:msos_s2s3_vol/remotepath3\n", + "server.conf": "" + } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_headless.json b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_headless.json new file mode 100644 index 000000000..4cedddfba --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_headless.json @@ -0,0 +1,118 @@ +{ + "links": { + "_reload": "/services/cluster/config/_reload", + "_acl": "/services/cluster/config/_acl" + }, + "origin": "https://localhost:8089/services/cluster/config", + "updated": "2020-10-28T21:37:07+00:00", + "generator": { + "build": "152fb4b2bb96", + "version": "8.0.6" + }, + "entry": [ + { + "name": "config", + "id": "https://localhost:8089/services/cluster/config/config", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/cluster/config/config", + "list": "/services/cluster/config/config", + "_reload": "/services/cluster/config/config/_reload", + "edit": "/services/cluster/config/config", + "disable": "/services/cluster/config/config/disable" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "access_logging_for_heartbeats": false, + "auto_rebalance_primaries": true, + "buckets_to_summarize": "primaries", + "cluster_label": "idxc_label", + "cxn_timeout": 60, + "decommission_force_finish_idle_time": 0, + "decommission_force_timeout": 180, + "disabled": false, + "eai:acl": null, + "forwarderdata_rcv_port": 0, + "forwarderdata_use_ssl": false, + "frozen_notifications_per_batch": 10, + "guid": "F643BA71-0D3C-4D63-A0BC-A1604AC928E3", + "heartbeat_period": 18446744073709552000, + "heartbeat_timeout": 60, + "master_uri": "https://127.0.0.1:8089", + "max_auto_service_interval": 30, + "max_fixup_time_ms": 5000, + "max_peer_build_load": 2, + "max_peer_rep_load": 5, + "max_peer_sum_rep_load": 5, + "max_peers_to_download_bundle": 5, + "max_primary_backups_per_service": 10, + "mode": "master", + "multisite": "true", + "notify_buckets_period": 10, + "notify_scan_min_period": 10, + "notify_scan_period": 10, + "percent_peers_to_restart": 10, + "ping_flag": true, + "quiet_period": 60, + "rcv_timeout": 60, + "rebalance_primaries_execution_limit_ms": 0, + "rebalance_threshold": 0.9, + "register_forwarder_address": "", + "register_replication_address": "", + "register_search_address": "", + "remote_storage_upload_timeout": 60, + "rep_cxn_timeout": 60, + "rep_max_rcv_timeout": 180, + "rep_max_send_timeout": 180, + "rep_rcv_timeout": 60, + "rep_send_timeout": 60, + "replication_factor": 3, + "replication_port": null, + "replication_use_ssl": false, + "report_remote_storage_bucket_upload_to_targets": false, + "reporting_delay_period": 30, + "restart_inactivity_timeout": 600, + "restart_timeout": 60, + "rolling_restart": "restart", + "search_factor": 3, + "search_files_retry_timeout": 600, + "secret": "********", + "send_timeout": 60, + "service_interval": 0, + "site": "site1", + "site_by_site": true, + "site_replication_factor": "{ origin:2, total:2 }", + "site_search_factor": "{ origin:2, total:2 }", + "summary_replication": "false", + "use_batch_discard": "true", + "use_batch_mask_changes": "true", + "use_batch_remote_rep_changes": "false" + } + } + ], + "paging": { + "total": 1, + "perPage": 10000000, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_service.json b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_service.json new file mode 100644 index 000000000..c3c71bcae --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_service.json @@ -0,0 +1,116 @@ +{ + "links": { + "_reload": "/services/cluster/config/_reload", + "_acl": "/services/cluster/config/_acl" + }, + "origin": "https://localhost:8089/services/cluster/config", + "updated": "2020-10-28T21:37:07+00:00", + "generator": { + "build": "152fb4b2bb96", + "version": "8.0.6" + }, + "entry": [ + { + "name": "config", + "id": "https://localhost:8089/services/cluster/config/config", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/cluster/config/config", + "list": "/services/cluster/config/config", + "_reload": "/services/cluster/config/config/_reload", + "edit": "/services/cluster/config/config", + "disable": "/services/cluster/config/config/disable" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "access_logging_for_heartbeats": false, + "auto_rebalance_primaries": true, + "buckets_to_summarize": "primaries", + "cluster_label": "idxc_label", + "cxn_timeout": 60, + "decommission_force_finish_idle_time": 0, + "decommission_force_timeout": 180, + "disabled": false, + "eai:acl": null, + "forwarderdata_rcv_port": 0, + "forwarderdata_use_ssl": false, + "frozen_notifications_per_batch": 10, + "guid": "F643BA71-0D3C-4D63-A0BC-A1604AC928E3", + "heartbeat_period": 18446744073709552000, + "heartbeat_timeout": 60, + "master_uri": "https://127.0.0.1:8089", + "max_auto_service_interval": 30, + "max_fixup_time_ms": 5000, + "max_peer_build_load": 2, + "max_peer_rep_load": 5, + "max_peer_sum_rep_load": 5, + "max_peers_to_download_bundle": 5, + "max_primary_backups_per_service": 10, + "mode": "master", + "multisite": "false", + "notify_buckets_period": 10, + "notify_scan_min_period": 10, + "notify_scan_period": 10, + "percent_peers_to_restart": 10, + "ping_flag": true, + "quiet_period": 60, + "rcv_timeout": 60, + "rebalance_primaries_execution_limit_ms": 0, + "rebalance_threshold": 0.9, + "register_forwarder_address": "", + "register_replication_address": "", + "register_search_address": "", + "remote_storage_upload_timeout": 60, + "rep_cxn_timeout": 60, + "rep_max_rcv_timeout": 180, + "rep_max_send_timeout": 180, + "rep_rcv_timeout": 60, + "rep_send_timeout": 60, + "replication_factor": 3, + "replication_port": null, + "replication_use_ssl": false, + "report_remote_storage_bucket_upload_to_targets": false, + "reporting_delay_period": 30, + "restart_inactivity_timeout": 600, + "restart_timeout": 60, + "rolling_restart": "restart", + "search_factor": 3, + "search_files_retry_timeout": 600, + "secret": "********", + "send_timeout": 60, + "service_interval": 0, + "site": "default", + "site_by_site": true, + "summary_replication": "false", + "use_batch_discard": "true", + "use_batch_mask_changes": "true", + "use_batch_remote_rep_changes": "false" + } + } + ], + "paging": { + "total": 1, + "perPage": 10000000, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_with_port.json b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_with_port.json new file mode 100644 index 000000000..c010e6f65 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/service_stack1_indexer_with_port.json @@ -0,0 +1,100 @@ +{ + "links": {}, + "origin": "https://localhost:8089/services/cluster/manager/info", + "updated": "2020-03-18T01:04:53+00:00", + "generator": { + "build": "a7f645ddaf91", + "version": "8.0.2" + }, + "entry": [ + { + "name": "master", + "id": "https://localhost:8089/services/cluster/manager/info/master", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/cluster/manager/info/master", + "list": "/services/cluster/manager/info/master" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "active_bundle": { + "bundle_path": "/opt/splunk/var/run/splunk/cluster/remote-bundle/506c58d5aeda1dd6017889e3186e7337-1583870198.bundle", + "checksum": "14310A4AABD23E85BBD4559C4A3B59F8", + "timestamp": 1583870198 + }, + "apply_bundle_status": { + "invalid_bundle": { + "bundle_path": "", + "bundle_validation_errors_on_master": [], + "checksum": "", + "timestamp": 0 + }, + "reload_bundle_issued": false, + "status": "None" + }, + "backup_and_restore_primaries": false, + "controlled_rolling_restart_flag": false, + "eai:acl": null, + "indexing_ready_flag": true, + "initialized_flag": true, + "label": "splunk-stack1-cluster-manager-0", + "last_check_restart_bundle_result": false, + "last_dry_run_bundle": { + "bundle_path": "", + "checksum": "", + "timestamp": 0 + }, + "last_validated_bundle": { + "bundle_path": "/opt/splunk/var/run/splunk/cluster/remote-bundle/0af7c0e95f313f7be3b0cb1d878df9a1-1583948640.bundle", + "checksum": "14310A4AABD23E85BBD4559C4A3B59F8", + "is_valid_bundle": true, + "timestamp": 1583948640 + }, + "latest_bundle": { + "bundle_path": "/opt/splunk/var/run/splunk/cluster/remote-bundle/506c58d5aeda1dd6017889e3186e7337-1583870198.bundle", + "checksum": "14310A4AABD23E85BBD4559C4A3B59F8", + "timestamp": 1583870198 + }, + "maintenance_mode": false, + "multisite": false, + "previous_active_bundle": { + "bundle_path": "", + "checksum": "", + "timestamp": 0 + }, + "primaries_backup_status": "No on-going (or) completed primaries backup yet. Check back again in few minutes if you expect a backup.", + "quiet_period_flag": false, + "rolling_restart_flag": false, + "rolling_restart_or_upgrade": false, + "service_ready_flag": true, + "start_time": 1583948636, + "summary_replication": "false" + } + } + ], + "paging": { + "total": 1, + "perPage": 30, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/shc_captain_info_response.json b/pkg/splunk/enterprise/testdata/fixtures/shc_captain_info_response.json new file mode 100644 index 000000000..e3d733bec --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/shc_captain_info_response.json @@ -0,0 +1,60 @@ +{ + "links": {}, + "origin": "https://localhost:8089/services/shcluster/captain/info", + "updated": "2020-03-15T16:36:42+00:00", + "generator": { + "build": "a7f645ddaf91", + "version": "8.0.2" + }, + "entry": [ + { + "name": "captain", + "id": "https://localhost:8089/services/shcluster/captain/info/captain", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/shcluster/captain/info/captain", + "list": "/services/shcluster/captain/info/captain" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "eai:acl": null, + "elected_captain": 1584139352, + "id": "A9D5FCCF-EB93-4E0A-93E1-45B56483EA7A", + "initialized_flag": true, + "label": "splunk-s2-search-head-0", + "maintenance_mode": false, + "mgmt_uri": "https://splunk-s2-search-head-0.splunk-s2-search-head-headless.splunk.svc.cluster.local:8089", + "min_peers_joined_flag": true, + "peer_scheme_host_port": "https://splunk-s2-search-head-0.splunk-s2-search-head-headless.splunk.svc.cluster.local:8089", + "rolling_restart_flag": false, + "service_ready_flag": true, + "start_time": 1584139291 + } + } + ], + "paging": { + "total": 1, + "perPage": 30, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/shc_member_info_response.json b/pkg/splunk/enterprise/testdata/fixtures/shc_member_info_response.json new file mode 100644 index 000000000..12266ac02 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/shc_member_info_response.json @@ -0,0 +1,67 @@ +{ + "links": {}, + "origin": "https://localhost:8089/services/shcluster/member/info", + "updated": "2020-03-15T16:30:38+00:00", + "generator": { + "build": "a7f645ddaf91", + "version": "8.0.2" + }, + "entry": [ + { + "name": "member", + "id": "https://localhost:8089/services/shcluster/member/info/member", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/shcluster/member/info/member", + "list": "/services/shcluster/member/info/member" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "active_historical_search_count": 0, + "active_realtime_search_count": 0, + "adhoc_searchhead": false, + "eai:acl": null, + "is_registered": true, + "last_heartbeat_attempt": 1584289836, + "maintenance_mode": false, + "no_artifact_replications": false, + "peer_load_stats_gla_15m": 0, + "peer_load_stats_gla_1m": 0, + "peer_load_stats_gla_5m": 0, + "peer_load_stats_max_runtime": 0, + "peer_load_stats_num_autosummary": 0, + "peer_load_stats_num_historical": 0, + "peer_load_stats_num_realtime": 0, + "peer_load_stats_num_running": 0, + "peer_load_stats_total_runtime": 0, + "restart_state": "NoRestart", + "status": "Up" + } + } + ], + "paging": { + "total": 1, + "perPage": 30, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/shc_member_remove_response.json b/pkg/splunk/enterprise/testdata/fixtures/shc_member_remove_response.json new file mode 100644 index 000000000..454e6d8fb --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/shc_member_remove_response.json @@ -0,0 +1,67 @@ +{ + "links": {}, + "origin": "https://localhost:8089/services/shcluster/member/info", + "updated": "2020-03-15T16:30:38+00:00", + "generator": { + "build": "a7f645ddaf91", + "version": "8.0.2" + }, + "entry": [ + { + "name": "member", + "id": "https://localhost:8089/services/shcluster/member/info/member", + "updated": "1970-01-01T00:00:00+00:00", + "links": { + "alternate": "/services/shcluster/member/info/member", + "list": "/services/shcluster/member/info/member" + }, + "author": "system", + "acl": { + "app": "", + "can_list": true, + "can_write": true, + "modifiable": false, + "owner": "system", + "perms": { + "read": [ + "admin", + "splunk-system-role" + ], + "write": [ + "admin", + "splunk-system-role" + ] + }, + "removable": false, + "sharing": "system" + }, + "content": { + "active_historical_search_count": 0, + "active_realtime_search_count": 0, + "adhoc_searchhead": false, + "eai:acl": null, + "is_registered": true, + "last_heartbeat_attempt": 1584289836, + "maintenance_mode": false, + "no_artifact_replications": false, + "peer_load_stats_gla_15m": 0, + "peer_load_stats_gla_1m": 0, + "peer_load_stats_gla_5m": 0, + "peer_load_stats_max_runtime": 0, + "peer_load_stats_num_autosummary": 0, + "peer_load_stats_num_historical": 0, + "peer_load_stats_num_realtime": 0, + "peer_load_stats_num_running": 0, + "peer_load_stats_total_runtime": 0, + "restart_state": "NoRestart", + "status": "ManualDetention" + } + } + ], + "paging": { + "total": 1, + "perPage": 30, + "offset": 0 + }, + "messages": [] +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_defaults.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_defaults.json new file mode 100644 index 000000000..a8c51a5e2 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_defaults.json @@ -0,0 +1,10 @@ +{ + "metadata": { + "name": "splunk-stack1-indexer-defaults", + "namespace": "test", + "creationTimestamp": null + }, + "data": { + "default.yml": "defaults_string" + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_headless.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_headless.json new file mode 100644 index 000000000..30a1254b8 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_headless.json @@ -0,0 +1,63 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-indexer-headless", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "http-hec", + "protocol": "TCP", + "port": 8088, + "targetPort": 8088 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + }, + { + "name": "tcp-s2s", + "protocol": "TCP", + "port": 9997, + "targetPort": 9997 + } + ], + "selector": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "clusterIP": "None", + "type": "ClusterIP" + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_multipart_service.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_multipart_service.json new file mode 100644 index 000000000..f3d1dff4a --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_multipart_service.json @@ -0,0 +1,63 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-indexer-service", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-cluster1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "http-hec", + "protocol": "TCP", + "port": 8088, + "targetPort": 8088 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + }, + { + "name": "tcp-s2s", + "protocol": "TCP", + "port": 9997, + "targetPort": 9997 + } + ], + "selector": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-cluster1-indexer" + } + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service.json new file mode 100644 index 000000000..4bbe5d804 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service.json @@ -0,0 +1,61 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-indexer-service", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "http-hec", + "protocol": "TCP", + "port": 8088, + "targetPort": 8088 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + }, + { + "name": "tcp-s2s", + "protocol": "TCP", + "port": 9997, + "targetPort": 9997 + } + ], + "selector": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service_with_custom_port.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service_with_custom_port.json new file mode 100644 index 000000000..a1974a230 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_indexer_service_with_custom_port.json @@ -0,0 +1,66 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-indexer-service", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "user-defined", + "port": 32000, + "targetPort": 6443 + }, + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "http-hec", + "protocol": "TCP", + "port": 8088, + "targetPort": 8088 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + }, + { + "name": "tcp-s2s", + "protocol": "TCP", + "port": 9997, + "targetPort": 9997 + } + ], + "selector": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_headless.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_headless.json new file mode 100644 index 000000000..14ba57f25 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_headless.json @@ -0,0 +1,58 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-search-head-headless", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "one": "two" + }, + "annotations": { + "a": "b" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + } + ], + "selector": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "clusterIP": "None", + "type": "ClusterIP", + "publishNotReadyAddresses": true + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_service.json b/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_service.json new file mode 100644 index 000000000..2f553cf67 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/splunk_search_head_service.json @@ -0,0 +1,57 @@ +{ + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "splunk-stack1-search-head-service", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "1": "2", + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "one": "two" + }, + "annotations": { + "a": "b" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "ports": [ + { + "name": "http-splunkweb", + "protocol": "TCP", + "port": 8000, + "targetPort": 8000 + }, + { + "name": "https-splunkd", + "protocol": "TCP", + "port": 8089, + "targetPort": 8089 + } + ], + "selector": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "type": "LoadBalancer" + }, + "status": { + "loadBalancer": {} + } +} diff --git a/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base.json new file mode 100644 index 000000000..ce3aeea59 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base_1.json new file mode 100644 index 000000000..32b2066a9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base_1.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_MASTER_URL", + "value": "splunk-stack1-license-manager-service.test.svc.cluster.local" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_base_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base_2.json new file mode 100644 index 000000000..f280b0c79 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_base_2.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_apps.json new file mode 100644 index 000000000..22d811186 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_apps.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account.json new file mode 100644 index 000000000..2db816afd --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account.json @@ -0,0 +1,306 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account_1.json new file mode 100644 index 000000000..a7e37445e --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account_1.json @@ -0,0 +1,310 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_manager_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account_2.json new file mode 100644 index 000000000..1577cbcac --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_manager_with_service_account_2.json @@ -0,0 +1,314 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "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" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "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": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-manager", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-manager-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_cluster_master_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base.json new file mode 100644 index 000000000..dc9814261 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base_1.json new file mode 100644 index 000000000..28c6d235d --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base_1.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_MASTER_URL", + "value": "splunk-stack1-license-manager-service.test.svc.cluster.local" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_base_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base_2.json new file mode 100644 index 000000000..d3a67e360 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_base_2.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "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_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_apps.json new file mode 100644 index 000000000..d6935325a --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_apps.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account.json new file mode 100644 index 000000000..686817216 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account.json @@ -0,0 +1,306 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account_1.json new file mode 100644 index 000000000..61b885a42 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account_1.json @@ -0,0 +1,310 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_cluster_master_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account_2.json new file mode 100644 index 000000000..b1742607e --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_cluster_master_with_service_account_2.json @@ -0,0 +1,314 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-cluster-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "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" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-cluster-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "localhost" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_cluster_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-cluster-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "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": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-cluster-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "cluster-master", + "app.kubernetes.io/part-of": "splunk-stack1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-cluster-master-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_deployer_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_base.json new file mode 100644 index 000000000..536c28e4e --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_base.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-deployer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-deployer-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "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_deployer" + }, + { + "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-stack1-deployer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-deployer-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_deployer_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_with_apps.json new file mode 100644 index 000000000..9e0385c23 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_with_apps.json @@ -0,0 +1,305 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-deployer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-deployer-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_deployer" + }, + { + "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-stack1-deployer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-deployer-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_deployer_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_with_service_account.json new file mode 100644 index 000000000..bcce50564 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_deployer_with_service_account.json @@ -0,0 +1,306 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-deployer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-deployer-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_deployer" + }, + { + "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-stack1-deployer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-deployer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "deployer", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-deployer-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_indexer_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base.json new file mode 100644 index 000000000..3853a51cc --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base.json @@ -0,0 +1,311 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_1.json new file mode 100644 index 000000000..3853a51cc --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_1.json @@ -0,0 +1,311 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_base_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_2.json new file mode 100644 index 000000000..356099083 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_2.json @@ -0,0 +1,316 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_base_3.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_3.json new file mode 100644 index 000000000..356099083 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_base_3.json @@ -0,0 +1,316 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account.json new file mode 100644 index 000000000..328004d6d --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account.json @@ -0,0 +1,317 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account_1.json new file mode 100644 index 000000000..72a160663 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account_1.json @@ -0,0 +1,321 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + }, + "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-stack1-indexer-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_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_indexer_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account_2.json new file mode 100644 index 000000000..ec2bb71d7 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_indexer_with_service_account_2.json @@ -0,0 +1,325 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-indexer", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer", + "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-stack1-indexer-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_CLUSTER_MASTER_URL", + "value": "splunk-manager1-cluster-manager-service" + }, + { + "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_indexer" + }, + { + "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-stack1-indexer" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer", + "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": "indexer", + "app.kubernetes.io/instance": "splunk-stack1-indexer", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "indexer", + "app.kubernetes.io/part-of": "splunk-manager1-indexer", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-indexer-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_license_manager_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_base.json new file mode 100644 index 000000000..2fe22aa99 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_base.json @@ -0,0 +1,297 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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_license_master" + }, + { + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_manager_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_base_1.json new file mode 100644 index 000000000..cd5c854bf --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_base_1.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_manager_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_apps.json new file mode 100644 index 000000000..40a3f1afb --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_apps.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_manager_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account.json new file mode 100644 index 000000000..d9eaf1b86 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account.json @@ -0,0 +1,302 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_manager_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account_1.json new file mode 100644 index 000000000..d344d4ee9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account_1.json @@ -0,0 +1,306 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_manager_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account_2.json new file mode 100644 index 000000000..00904a1f2 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_manager_with_service_account_2.json @@ -0,0 +1,310 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-manager", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager", + "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" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-manager-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-manager" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager", + "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": "license-manager", + "app.kubernetes.io/instance": "splunk-stack1-license-manager", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-manager", + "app.kubernetes.io/part-of": "splunk-stack1-license-manager", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-manager-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_license_master_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_base.json new file mode 100644 index 000000000..766fee177 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_base.json @@ -0,0 +1,297 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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_license_master" + }, + { + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_license_master_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_base_1.json new file mode 100644 index 000000000..d3083fc3d --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_base_1.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_license_master_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_apps.json new file mode 100644 index 000000000..ba6e50b75 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_apps.json @@ -0,0 +1,301 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_license_master_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account.json new file mode 100644 index 000000000..9bb6fbb12 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account.json @@ -0,0 +1,302 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_license_master_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account_1.json new file mode 100644 index 000000000..5a2aa9de3 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account_1.json @@ -0,0 +1,306 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_license_master_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account_2.json new file mode 100644 index 000000000..0da2339fe --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_license_master_with_service_account_2.json @@ -0,0 +1,310 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-license-master", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master", + "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" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-license-master-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "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/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_license_master" + }, + { + "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" + }, + { + "name": "SPLUNK_LICENSE_URI", + "value": "/mnt/splunk.lic" + } + ], + "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-stack1-license-master" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master", + "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": "license-master", + "app.kubernetes.io/instance": "splunk-stack1-license-master", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "license-master", + "app.kubernetes.io/part-of": "splunk-stack1-license-master", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-license-master-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_monitoring_console_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_base.json new file mode 100644 index 000000000..b8637e02f --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_base.json @@ -0,0 +1,339 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-monitoring-console-defaults", + "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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_monitor" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_base_1.json new file mode 100644 index 000000000..575e0b774 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_base_1.json @@ -0,0 +1,340 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-monitoring-console-defaults", + "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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_monitor" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_apps.json new file mode 100644 index 000000000..2fe9dcb12 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_apps.json @@ -0,0 +1,271 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "mnt-splunk-etc", + "emptyDir": {} + }, + { + "name": "mnt-splunk-var", + "emptyDir": {} + }, + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "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_monitor" + }, + { + "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": "mnt-splunk-etc", + "mountPath": "/opt/splunk/etc" + }, + { + "name": "mnt-splunk-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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_with_defaults.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_defaults.json new file mode 100644 index 000000000..17cff62f0 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_defaults.json @@ -0,0 +1,315 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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-stack1-monitoring-console-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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "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_monitor" + }, + { + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account.json new file mode 100644 index 000000000..450968c85 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account.json @@ -0,0 +1,344 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-monitoring-console-defaults", + "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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_monitor" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account_1.json new file mode 100644 index 000000000..e3fb99601 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account_1.json @@ -0,0 +1,348 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-monitoring-console-defaults", + "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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_monitor" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_monitoring_console_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account_2.json new file mode 100644 index 000000000..088071c37 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_monitoring_console_with_service_account_2.json @@ -0,0 +1,339 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-monitoring-console", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + }, + "annotations": { + "monitoringConsoleConfigRev": "", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-monitoring-console-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-monitoring-console-defaults", + "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" + } + ], + "envFrom": [ + { + "configMapRef": { + "name": "splunk-stack1-monitoring-console" + } + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_monitor" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-monitoring-console" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "monitoring-console", + "app.kubernetes.io/instance": "splunk-stack1-monitoring-console", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "monitoring-console", + "app.kubernetes.io/part-of": "splunk-stack1-monitoring-console" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-monitoring-console-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_search_head_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base.json new file mode 100644 index 000000000..b99dfe27e --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base.json @@ -0,0 +1,309 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 3, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_1.json new file mode 100644 index 000000000..279240914 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_1.json @@ -0,0 +1,309 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 4, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_base_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_2.json new file mode 100644 index 000000000..9d260cb1e --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_2.json @@ -0,0 +1,313 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 5, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_base_3.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_3.json new file mode 100644 index 000000000..9e16b0ff9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_3.json @@ -0,0 +1,313 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_base_4.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_4.json new file mode 100644 index 000000000..9e16b0ff9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_4.json @@ -0,0 +1,313 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_base_5.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_5.json new file mode 100644 index 000000000..9e16b0ff9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_base_5.json @@ -0,0 +1,313 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account.json new file mode 100644 index 000000000..19902d0c5 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account.json @@ -0,0 +1,314 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account_1.json new file mode 100644 index 000000000..254e6b3e5 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account_1.json @@ -0,0 +1,318 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_search_head_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account_2.json new file mode 100644 index 000000000..bfeece12b --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_search_head_with_service_account_2.json @@ -0,0 +1,322 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-search-head", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 6, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "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" + } + }, + "spec": { + "volumes": [ + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-search-head-secret-v1", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "splunk", + "image": "splunk/splunk", + "ports": [ + { + "name": "http-splunkweb", + "containerPort": 8000, + "protocol": "TCP" + }, + { + "name": "https-splunkd", + "containerPort": 8089, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_SEARCH_HEAD_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-1.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-2.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-3.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-4.splunk-stack1-search-head-headless.test.svc.cluster.local,splunk-stack1-search-head-5.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_SEARCH_HEAD_CAPTAIN_URL", + "value": "splunk-stack1-search-head-0.splunk-stack1-search-head-headless.test.svc.cluster.local" + }, + { + "name": "SPLUNK_DEPLOYER_URL", + "value": "splunk-stack1-deployer-service" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack1-cluster-manager-service.test2.svc.cluster.local" + }, + { + "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_search_head" + }, + { + "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-stack1-search-head" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "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": "search-head", + "app.kubernetes.io/instance": "splunk-stack1-search-head", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "search-head", + "app.kubernetes.io/part-of": "splunk-stack1-search-head", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-search-head-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_standalone_base.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_base.json new file mode 100644 index 000000000..53ebd48d4 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_base.json @@ -0,0 +1,307 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "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-stack1-standalone-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" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + } + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + } + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-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_standalone_base_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_base_1.json new file mode 100644 index 000000000..cc78c8b17 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_base_1.json @@ -0,0 +1,263 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "annotations": { + "traffic.sidecar.istio.io/excludeOutboundPorts": "8089,8191,9997", + "traffic.sidecar.istio.io/includeInboundPorts": "8000,8088" + } + }, + "spec": { + "volumes": [ + { + "name": "mnt-splunk-etc", + "emptyDir": {} + }, + { + "name": "mnt-splunk-var", + "emptyDir": {} + }, + { + "name": "splunk-test-probe-configmap", + "configMap": { + "name": "splunk-test-probe-configmap", + "defaultMode": 365 + } + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-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" + } + ], + "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": "mnt-splunk-etc", + "mountPath": "/opt/splunk/etc" + }, + { + "name": "mnt-splunk-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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "default-scheduler" + } + }, + "serviceName": "splunk-stack1-standalone-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_standalone_with_apps.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_apps.json new file mode 100644 index 000000000..1f458c7d6 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_apps.json @@ -0,0 +1,331 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-standalone-defaults", + "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" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_search_head" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-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_standalone_with_defaults.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_defaults.json new file mode 100644 index 000000000..2cff57c5d --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_defaults.json @@ -0,0 +1,331 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-standalone-defaults", + "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" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_search_head" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-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_standalone_with_service_account.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account.json new file mode 100644 index 000000000..62e93dfe9 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account.json @@ -0,0 +1,332 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-standalone-defaults", + "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" + } + ], + "env": [ + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_search_head" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-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_standalone_with_service_account_1.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account_1.json new file mode 100644 index 000000000..f52bd4fb5 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account_1.json @@ -0,0 +1,336 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + }, + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-standalone-defaults", + "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" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_search_head" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-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_standalone_with_service_account_2.json b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account_2.json new file mode 100644 index 000000000..d94fc0819 --- /dev/null +++ b/pkg/splunk/enterprise/testdata/fixtures/statefulset_stack1_standalone_with_service_account_2.json @@ -0,0 +1,340 @@ +{ + "kind": "StatefulSet", + "apiVersion": "apps/v1", + "metadata": { + "name": "splunk-stack1-standalone", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + }, + "ownerReferences": [ + { + "apiVersion": "", + "kind": "", + "name": "stack1", + "uid": "", + "controller": true + } + ] + }, + "spec": { + "replicas": 1, + "selector": { + "matchLabels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone", + "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": "defaults" + }, + { + "name": "mnt-splunk-secrets", + "secret": { + "secretName": "splunk-stack1-standalone-secret-v1", + "defaultMode": 420 + } + }, + { + "name": "mnt-splunk-defaults", + "configMap": { + "name": "splunk-stack1-standalone-defaults", + "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" + } + ], + "env": [ + { + "name": "TEST_ENV_VAR", + "value": "test_value" + }, + { + "name": "SPLUNK_CLUSTER_MASTER_URL", + "value": "splunk-stack2-cluster-manager-service" + }, + { + "name": "SPLUNK_HOME", + "value": "/opt/splunk" + }, + { + "name": "SPLUNK_START_ARGS", + "value": "--accept-license" + }, + { + "name": "SPLUNK_DEFAULTS_URL", + "value": "/mnt/splunk-defaults/default.yml,/mnt/defaults/defaults.yml,/mnt/apps/apps.yml,/mnt/splunk-secrets/default.yml" + }, + { + "name": "SPLUNK_HOME_OWNERSHIP_ENFORCEMENT", + "value": "false" + }, + { + "name": "SPLUNK_ROLE", + "value": "splunk_search_head" + }, + { + "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": "defaults", + "mountPath": "/mnt/defaults" + }, + { + "name": "mnt-splunk-secrets", + "mountPath": "/mnt/splunk-secrets" + }, + { + "name": "mnt-splunk-defaults", + "mountPath": "/mnt/splunk-defaults" + } + ], + "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-stack1-standalone" + ] + } + ] + }, + "topologyKey": "kubernetes.io/hostname" + } + } + ] + } + }, + "schedulerName": "custom-scheduler" + } + }, + "volumeClaimTemplates": [ + { + "metadata": { + "name": "pvc-etc", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "10Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + }, + { + "metadata": { + "name": "pvc-var", + "namespace": "test", + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/component": "standalone", + "app.kubernetes.io/instance": "splunk-stack1-standalone", + "app.kubernetes.io/managed-by": "splunk-operator", + "app.kubernetes.io/name": "standalone", + "app.kubernetes.io/part-of": "splunk-stack1-standalone", + "app.kubernetes.io/test-extra-label": "test-extra-label-value" + } + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "100Gi" + } + }, + "storageClassName": "gp2" + }, + "status": {} + } + ], + "serviceName": "splunk-stack1-standalone-headless", + "podManagementPolicy": "Parallel", + "updateStrategy": { + "type": "OnDelete" + } + }, + "status": { + "replicas": 0, + "availableReplicas": 0 + } +} \ No newline at end of file diff --git a/pkg/splunk/enterprise/util.go b/pkg/splunk/enterprise/util.go index 701c4beda..70b9b8f8a 100644 --- a/pkg/splunk/enterprise/util.go +++ b/pkg/splunk/enterprise/util.go @@ -16,7 +16,9 @@ package enterprise import ( + "bytes" "context" + "encoding/json" "errors" "fmt" "io" @@ -29,6 +31,7 @@ import ( "strings" "sync" "syscall" + "testing" "time" enterpriseApi "github.com/splunk/splunk-operator/api/v4" @@ -2490,3 +2493,21 @@ func changeAnnotations(ctx context.Context, c splcommon.ControllerClient, image err := c.Update(ctx, cr) return err } + +// loadFixture loads a JSON fixture file from the testdata/fixtures directory +// and returns it as compact JSON (minified, single-line) +func loadFixture(t *testing.T, filename string) string { + t.Helper() + path := filepath.Join("testdata", "fixtures", filename) + data, err := os.ReadFile(path) + if err != nil { + t.Fatalf("Failed to load fixture %s: %v", filename, err) + } + + // Compact the JSON to match the output from json.Marshal + var compactJSON bytes.Buffer + if err := json.Compact(&compactJSON, data); err != nil { + t.Fatalf("Failed to compact JSON from fixture %s: %v", filename, err) + } + return compactJSON.String() +} diff --git a/pkg/splunk/enterprise/util_test.go b/pkg/splunk/enterprise/util_test.go index 5e69bfdb7..e717e82da 100644 --- a/pkg/splunk/enterprise/util_test.go +++ b/pkg/splunk/enterprise/util_test.go @@ -470,7 +470,7 @@ func TestApplySmartstoreConfigMap(t *testing.T) { configTester2(t, "ApplySmartstoreConfigMap()", f, want) } - test(client, &cr, &cr.Spec.SmartStore, `{"metadata":{"name":"splunk-idxCluster--smartstore","namespace":"test","creationTimestamp":null,"ownerReferences":[{"apiVersion":"","kind":"","name":"idxCluster","uid":"","controller":true}]},"data":{"conftoken":"1601945361","indexes.conf":"[default]\nrepFactor = auto\nmaxDataSize = auto\nhomePath = $SPLUNK_DB/$_index_name/db\ncoldPath = $SPLUNK_DB/$_index_name/colddb\nthawedPath = $SPLUNK_DB/$_index_name/thaweddb\n \n[volume:msos_s2s3_vol]\nstorageType = remote\npath = s3://testbucket-rs-london\nremote.s3.access_key = abcdJDckRkxhMEdmSk5FekFRRzBFOXV6bGNldzJSWE9IenhVUy80aa\nremote.s3.secret_key = g4NVp0a29PTzlPdGczWk1vekVUcVBSa0o4NkhBWWMvR1NadDV4YVEy\nremote.s3.endpoint = https://s3-eu-west-2.amazonaws.com\nremote.s3.auth_region = \n \n[salesdata1]\nremotePath = volume:msos_s2s3_vol/remotepath1\n\n[salesdata2]\nremotePath = volume:msos_s2s3_vol/remotepath2\n\n[salesdata3]\nremotePath = volume:msos_s2s3_vol/remotepath3\n","server.conf":""}}`) + test(client, &cr, &cr.Spec.SmartStore, loadFixture(t, "configmap_smartstore_volumes.json")) // Missing Volume config should return an error cr.Spec.SmartStore.VolList = nil