From 8aa7e863eb3931455516121e9b74b26cd4ae42e4 Mon Sep 17 00:00:00 2001 From: Rock Baek Date: Thu, 1 Jul 2021 10:11:40 -0700 Subject: [PATCH] change default image (#29) * 0.2.0 --- .github/workflows/ci_build_test.yaml | 7 -- .gitignore | 1 + charts/opentelemetry-collector-0.1.0.tgz | Bin 8974 -> 0 bytes charts/sck-otel/Chart.yaml | 2 +- charts/sck-otel/templates/_config.tpl | 4 +- charts/sck-otel/values.yaml | 5 +- ci_scripts/k8s-splunk.yml | 2 +- ci_scripts/sck_otel_values.yaml | 7 +- test/README.md | 7 +- test/conftest.py | 16 +++ test/k8s_logging_tests/test_config_logging.py | 16 +-- test/test_setup.yaml | 114 ++++++++++-------- 12 files changed, 104 insertions(+), 77 deletions(-) delete mode 100644 charts/opentelemetry-collector-0.1.0.tgz diff --git a/.github/workflows/ci_build_test.yaml b/.github/workflows/ci_build_test.yaml index 51adec3..1a1c643 100644 --- a/.github/workflows/ci_build_test.yaml +++ b/.github/workflows/ci_build_test.yaml @@ -95,13 +95,6 @@ jobs: - name: Install Splunk run: | - # Wait until minikube is ready - kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml - export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}' - until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do - echo "wait for minikube ready ..." - sleep 1; - done kubectl get nodes # Install Splunk on minikube kubectl apply -f ci_scripts/k8s-splunk.yml diff --git a/.gitignore b/.gitignore index 2770120..dbaf060 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .tmp/ .idea/ .deploy/ +**/__pycache__/ \ No newline at end of file diff --git a/charts/opentelemetry-collector-0.1.0.tgz b/charts/opentelemetry-collector-0.1.0.tgz deleted file mode 100644 index 894d6063b6eb3407a2738765f8199c13df1cb77b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8974 zcmV+pBk|lH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1rB7*u^lL+`^ z^yZL`$M^0U6U6mR7iw_`WA0oZr#at2=WvhD`3_0M+Mp?B{!XEm?qQry!Qb0JAK(if9Gte~TF@AG-(Rk#hXo-qcI-&N<+d`g70LKOCL z9|*)gU*eXssnv8T%Ln6>jr9#~35&(R)m5#5wm!_T z?7I(r%t;?#Vwx(x4NOGu*X~*>+n#W*k ztTbG5{lOg=2H3tZ_!h6?(V|T`CZhvcps%~d6eeCM<{WMH& zToi$h9-g(g78YJ-)eV8#p+?Y4F z%jyDQ(3!QQaMEExa3_d?axxfm6KjAbtc9z&~cG<)o*4YM|Cl)OzAM zD@aTylnAA6fUbgD0k*37L|gEc)YHE_A?tgBD1A9GaSmJYx*E1{eea@{fvcl@=}GI` z2~1~#NZ?4bub^6+mt+TF6ChEbDaq9^A_*#ml^Awy;8qZ>{nQ$v9lZrG>n%lxVM zhafyc!=Ua814Zfw0ac2B$wgwt?SNk-Zd2lTZofM^sC8N2q8`LqLg8l1RX(& zqw4BR-6+iqG?PB#DiN=O8?vt2qEk47Xe$_VWp z9A?J-ECaE5u)B9cTM8MhNg%MBoZ%`WX-4?eF4z5O+Db;vMuD1MI~ z`aW-=evS&vaYm%R=ghXEi)Ia%e<{k(^^IDIZ;U|aK=*mDh3Yr{N5NJ-BDU6w-7TwD zN$zM#XypbpHJE>EJIrtOEVKV{%5G`-)6WX~|C7hNyUqA-hmSY$pYP<^*#9>6zm5HG zWB=RO|2Fo&KeGK#<=vS6Hm1Knmg&z8n2qIcWBJ=y{(eW6Kb7vszSF(BG2m[^_]+)_(?P[^_]+)_(?P[^\/]+)\/(?P[^\._]+)\/(?P\d+)\.log$' - parse_from: $$attributes.file_path + parse_from: $$attributes["file.path"] # Move out attributes to Attributes - type: metadata resource: diff --git a/charts/sck-otel/values.yaml b/charts/sck-otel/values.yaml index 2acde22..c56b029 100644 --- a/charts/sck-otel/values.yaml +++ b/charts/sck-otel/values.yaml @@ -87,10 +87,11 @@ batch: send_batch_max_size: 0 image: - repository: otel/opentelemetry-collector-contrib + repository: rock1017/otelcontribcol + # repository: otel/opentelemetry-collector-contrib pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "" + tag: "0.30.0" imagePullSecrets: [] # OpenTelemetry Collector executable diff --git a/ci_scripts/k8s-splunk.yml b/ci_scripts/k8s-splunk.yml index 543c6ca..e5de7a0 100644 --- a/ci_scripts/k8s-splunk.yml +++ b/ci_scripts/k8s-splunk.yml @@ -9,7 +9,7 @@ spec: runAsGroup: 0 containers: - name: splunk - image: splunk/splunk:latest + image: splunk/splunk:8.2.0 ports: - containerPort: 8000 hostPort: 8000 diff --git a/ci_scripts/sck_otel_values.yaml b/ci_scripts/sck_otel_values.yaml index af18f79..ca9af6a 100644 --- a/ci_scripts/sck_otel_values.yaml +++ b/ci_scripts/sck_otel_values.yaml @@ -65,9 +65,6 @@ containers: from: namespace - key: splunk.com/exclude from: namespace - - key: splunk.com/customField - tag_name: customField - from: namespace listOfLabels: - key: app from: pod @@ -79,10 +76,10 @@ customMetadata: customfield2: customvalue2 image: - repository: otel/opentelemetry-collector-contrib + repository: rock1017/otelcontribcol pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. - tag: "" + tag: "0.30.0" imagePullSecrets: [] # OpenTelemetry Collector executable diff --git a/test/README.md b/test/README.md index 1055987..d256e09 100644 --- a/test/README.md +++ b/test/README.md @@ -34,7 +34,7 @@ curl -X POST -u admin:helloworld -k https://localhost:8089/servicesNS/nobody/splunk_httpinput/data/inputs/http/http/enable # Create new HEC token - curl -X POST -u admin:helloworld -k -d "name=splunk_hec_token&token=a6b5e77f-d5f6-415a-bd43-930cecb12959&disabled=0&index=main&indexes=main,circleci_events,ns-anno,pod-anno" https://localhost:8089/servicesNS/nobody/splunk_httpinput/data/inputs/http + curl -X POST -u admin:helloworld -k -d "name=splunk_hec_token&token=a6b5e77f-d5f6-415a-bd43-930cecb12959&disabled=0&index=main&indexes=main,ci_events,ns-anno,pod-anno" https://localhost:8089/servicesNS/nobody/splunk_httpinput/data/inputs/http # Restart Splunk curl -k -u admin:helloworld https://localhost:8089/services/server/control/restart -X POST @@ -69,11 +69,12 @@ 2. Install the dependencies ``` pip install -r requirements.txt + export PYTHONWARNINGS="ignore:Unverified HTTPS request" ``` 3. Start the test with the required options configured ``` - python -m pytest \ - --splunkd-url https://localhost:8089 \ + python -m pytest \ + --splunkd-url https://localhost:8089 \ --splunk-user admin --splunk-password helloworld \ -p no:warnings -s ``` diff --git a/test/conftest.py b/test/conftest.py index cd29c65..0f87ac0 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -17,6 +17,7 @@ import pytest import time import os +from .common import check_events_from_splunk def pytest_addoption(parser): parser.addoption("--splunkd-url", @@ -35,6 +36,21 @@ def pytest_addoption(parser): # os.system('docker pull $CI_DATAGEN_IMAGE && kubectl apply -f test_setup.yaml') # time.sleep(60) +# Print events ingested in splunk for debugging +def pytest_unconfigure(config): + indexes = ["main", "ci_events", "ns-anno", "pod-anno"] + for index in indexes: + search_query = "index=" + index + " | fields *" + events = check_events_from_splunk(start_time="-1h@h", + url=config.getoption("--splunkd-url"), + user=config.getoption("--splunk-user"), + query=["search {0}".format( + search_query)], + password=config.getoption("--splunk-password")) + print("index=" + index + " event count=" + str(len(events))) + for event in events: + print(event) + @pytest.fixture(scope="function") def setup(request): diff --git a/test/k8s_logging_tests/test_config_logging.py b/test/k8s_logging_tests/test_config_logging.py index a1d7a5e..e65806e 100644 --- a/test/k8s_logging_tests/test_config_logging.py +++ b/test/k8s_logging_tests/test_config_logging.py @@ -63,20 +63,20 @@ def test_label_collection(setup, label, index, expected): assert len(events) >= expected -@pytest.mark.parametrize("container_name,expected", [ - ("pod-w-index-w-ns-index", 1), - ("pod-wo-index-w-ns-index", 1), - ("pod-w-index-wo-ns-index", 1), - ("pod-wo-index-wo-ns-index", 1), +@pytest.mark.parametrize("index,container_name,expected", [ + ("pod-anno", "pod-w-index-w-ns-index", 1), + ("ns-anno", "pod-wo-index-w-ns-index", 1), + ("pod-anno", "pod-w-index-wo-ns-index", 1), + ("ci_events", "pod-wo-index-wo-ns-index", 1), ]) -def test_annotation_routing(setup, container_name, expected): +def test_annotation_routing(setup, index, container_name, expected): ''' Test annotation routing feature. it tests different combinations of namespace annotations and pod annotations. ''' logger.info("testing test_annotation_routing pod={0} expected={1} event(s)".format( container_name, expected)) - search_query = "index=* container_name::" + container_name + search_query = "index=" + index + " container_name::" + container_name events = check_events_from_splunk(start_time="-1h@h", url=setup["splunkd_url"], user=setup["splunk_user"], @@ -252,7 +252,7 @@ def test_custom_metadata_fields(setup, field,value, expected): @pytest.mark.parametrize("label,index,value,expected", [ ("pod-w-index-wo-ns-index", "pod-anno", "pod-value-2", 1), - ("pod-wo-index-w-ns-index", "ns-anno", "ns-value", 1), + # ("pod-wo-index-w-ns-index", "ns-anno", "ns-value", 1), ("pod-w-index-w-ns-index", "pod-anno", "pod-value-1", 1) ]) def test_custom_metadata_fields_annotations(setup, label, index, value, expected): diff --git a/test/test_setup.yaml b/test/test_setup.yaml index 553f5b3..74690a8 100644 --- a/test/test_setup.yaml +++ b/test/test_setup.yaml @@ -20,16 +20,13 @@ metadata: splunk.com/index: ns-anno splunk.com/exclude: "true" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-w-index-w-ns-index namespace: ns-w-index spec: - replicas: 1 - selector: - matchLabels: - app: pod-w-index-w-ns-index + parallelism: 1 template: metadata: labels: @@ -39,22 +36,25 @@ spec: splunk.com/sourcetype: "sourcetype-anno" splunk.com/customField: pod-value-1 spec: + restartPolicy: Never containers: - name: pod-w-index-w-ns-index image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-wo-index-w-ns-index namespace: ns-w-index spec: - replicas: 1 - selector: - matchLabels: - app: pod-wo-index-w-ns-index + parallelism: 1 template: metadata: labels: @@ -62,22 +62,25 @@ spec: annotations: splunk.com/exclude: "false" spec: + restartPolicy: Never containers: - name: pod-wo-index-w-ns-index image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-w-index-wo-ns-index namespace: ns-wo-index spec: - replicas: 1 - selector: - matchLabels: - app: pod-w-index-wo-ns-index + parallelism: 1 template: metadata: labels: @@ -86,22 +89,25 @@ spec: splunk.com/index: "pod-anno" splunk.com/customField: pod-value-2 spec: + restartPolicy: Never containers: - name: pod-w-index-wo-ns-index image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-w-index-w-ns-exclude namespace: ns-w-exclude spec: - replicas: 1 - selector: - matchLabels: - app: pod-w-index-w-ns-exclude + parallelism: 1 template: metadata: labels: @@ -109,22 +115,25 @@ spec: annotations: splunk.com/index: "pod-anno" spec: + restartPolicy: Never containers: - name: pod-w-index-w-ns-exclude image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-w-exclude-wo-ns-exclude namespace: ns-w-index spec: - replicas: 1 - selector: - matchLabels: - app: pod-w-index-w-ns-exclude + parallelism: 1 template: metadata: labels: @@ -132,29 +141,38 @@ spec: annotations: splunk.com/exclude: "true" spec: + restartPolicy: Never containers: - name: pod-w-index-w-ns-exclude image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1" --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: name: pod-wo-index-wo-ns-index namespace: ns-wo-index spec: - replicas: 1 - selector: - matchLabels: - app: pod-wo-index-wo-ns-index + parallelism: 1 template: metadata: labels: app: pod-wo-index-wo-ns-index spec: + restartPolicy: Never containers: - name: pod-wo-index-wo-ns-index image: rock1017/log-generator:2.2.4 - args: - - "1" + env: + - name: MESSAGE_COUNT + value: "10" + - name: SIZE + value: "256" + - name: FREQ + value: "1"