Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 2d88541

Browse files
authored
1.1.7 (#100)
1 parent d0e2fc0 commit 2d88541

File tree

13 files changed

+312
-177
lines changed

13 files changed

+312
-177
lines changed

.circleci/config.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.circleci/trigger_func_test.sh

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
name: CI Build Test
2+
3+
on:
4+
pull_request:
5+
branches-ignore:
6+
- /^release\/.*/
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Ruby 2.6.1
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: 2.6.1
20+
21+
- name: Install dependencies
22+
run: |
23+
sudo ci_scripts/install_dep.sh
24+
25+
- name: Builder
26+
run: |
27+
rake build -t -v
28+
cp -R pkg /tmp
29+
30+
- name: Cache pkg
31+
uses: actions/cache@v1
32+
with:
33+
path: /tmp
34+
key: ${{ runner.os }}-build
35+
36+
unit-test:
37+
runs-on: ubuntu-20.04
38+
needs:
39+
- build
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v2
43+
44+
- name: Install dependencies
45+
run: |
46+
sudo ci_scripts/install_dep.sh
47+
48+
- uses: actions/cache@v2
49+
with:
50+
path: /tmp
51+
key: ${{ runner.os }}-build
52+
53+
- name: Run unit tests
54+
run: |
55+
bundle exec rake test -t -v
56+
57+
func-test:
58+
needs:
59+
- unit-test
60+
runs-on: ubuntu-20.04
61+
env:
62+
CI_SPLUNK_PORT: 8089
63+
CI_SPLUNK_USERNAME: admin
64+
CI_SPLUNK_HEC_TOKEN: a6b5e77f-d5f6-415a-bd43-930cecb12959
65+
CI_SPLUNK_PASSWORD: helloworld
66+
CI_INDEX_EVENTS: ci_events
67+
CI_INDEX_OBJECTS: ci_objects
68+
CI_INDEX_METRICS: ci_metrics
69+
KUBERNETES_VERSION: v1.15.2
70+
MINIKUBE_VERSION: v1.21.0
71+
GITHUB_ACTIONS: true
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
77+
- name: Prepare container build
78+
id: prep
79+
run: |
80+
VERSION=`cat VERSION`
81+
TAGS=splunk/k8s-metrics:recent
82+
83+
echo ::set-output name=tags::${TAGS}
84+
echo ::set-output name=version::${VERSION}
85+
86+
- name: Set up QEMU
87+
uses: docker/setup-qemu-action@master
88+
with:
89+
platforms: all
90+
91+
- name: Set up Docker Buildx
92+
id: buildx
93+
uses: docker/setup-buildx-action@master
94+
95+
- name: Build multi-arch kubernetes-metrics image
96+
uses: docker/build-push-action@v2
97+
with:
98+
builder: ${{ steps.buildx.outputs.name }}
99+
context: .
100+
file: ./docker/Dockerfile
101+
platforms: linux/amd64
102+
push: false
103+
load: true
104+
tags: ${{ steps.prep.outputs.tags }}
105+
build-args: VERSION=${{ steps.prep.outputs.version }}
106+
107+
- name: Check kubernetes-metrics image
108+
run: |
109+
docker image ls
110+
111+
- name: Setup Minikube
112+
run: |
113+
# Install Kubectl
114+
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl
115+
chmod +x kubectl
116+
sudo mv kubectl /usr/local/bin/
117+
mkdir -p ${HOME}/.kube
118+
touch ${HOME}/.kube/config
119+
# Install Minikube
120+
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
121+
chmod +x minikube
122+
sudo mv minikube /usr/local/bin/
123+
# Start Minikube and Wait
124+
minikube start --driver=docker --container-runtime=docker --cpus 2 --memory 4096 --kubernetes-version=${KUBERNETES_VERSION} --no-vtx-check
125+
export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
126+
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
127+
sleep 1;
128+
done
129+
130+
- name: Install Splunk
131+
run: |
132+
# Wait until minikube is ready
133+
kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
134+
export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
135+
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
136+
echo "wait for minikube ready ..."
137+
sleep 1;
138+
done
139+
kubectl get nodes
140+
# Install Splunk on minikube
141+
kubectl apply -f ci_scripts/k8s-splunk.yml
142+
# Wait until splunk is ready
143+
until kubectl logs splunk --tail=2 | grep -q 'Ansible playbook complete'; do
144+
sleep 1;
145+
done
146+
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
147+
# Setup Indexes
148+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=$CI_INDEX_EVENTS -d datatype=event
149+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=$CI_INDEX_OBJECTS -d datatype=event
150+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=$CI_INDEX_METRICS -d datatype=metric
151+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=default-events -d datatype=event
152+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=ns-anno -d datatype=event
153+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/data/indexes -d name=pod-anno -d datatype=event
154+
# Enable HEC services
155+
curl -X POST -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD -k https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/servicesNS/nobody/splunk_httpinput/data/inputs/http/http/enable
156+
# Create new HEC token
157+
curl -X POST -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD -k -d "name=splunk_hec_token&token=a6b5e77f-d5f6-415a-bd43-930cecb12959&disabled=0&index=default-events&indexes=default-events,$CI_INDEX_METRICS,$CI_INDEX_OBJECTS,$CI_INDEX_EVENTS,ns-anno,pod-anno" https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/servicesNS/nobody/splunk_httpinput/data/inputs/http
158+
# Restart Splunk
159+
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/server/control/restart -X POST
160+
161+
- name: Deploy k8s connector
162+
run: |
163+
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
164+
ci_scripts/deploy_connector.sh
165+
166+
- name: Deploy log generator
167+
run: |
168+
cd /opt/splunk-connect-for-kubernetes
169+
kubectl apply -f test/test_setup.yaml
170+
sleep 60
171+
172+
- uses: actions/setup-python@v2
173+
with:
174+
python-version: 3.7
175+
176+
- name: Run functional tests
177+
run: |
178+
echo "check the pods"
179+
kubectl get pods -A
180+
cd /opt/splunk-connect-for-kubernetes
181+
kubectl get nodes
182+
export PYTHONWARNINGS="ignore:Unverified HTTPS request"
183+
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
184+
cd test
185+
pip install --upgrade pip
186+
pip install -r requirements.txt
187+
echo "Running functional tests....."
188+
python -m pytest \
189+
--splunkd-url https://$CI_SPLUNK_HOST:8089 \
190+
--splunk-user admin \
191+
--splunk-password $CI_SPLUNK_PASSWORD \
192+
-p no:warnings -s

Gemfile.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
fluent-plugin-kubernetes-metrics (1.1.6)
4+
fluent-plugin-kubernetes-metrics (1.1.7)
55
fluentd (>= 1.9.1)
66
kubeclient (~> 4.6.0)
77
multi_json (~> 1.14.1)
@@ -19,18 +19,18 @@ GEM
1919
docile (1.4.0)
2020
domain_name (0.5.20190701)
2121
unf (>= 0.0.5, < 1.0.0)
22-
ffi (1.15.3)
22+
ffi (1.15.4)
2323
ffi-compiler (1.0.1)
2424
ffi (>= 1.0.0)
2525
rake
26-
fluentd (1.13.2)
26+
fluentd (1.14.2)
2727
bundler
2828
cool.io (>= 1.4.5, < 2.0.0)
2929
http_parser.rb (>= 0.5.1, < 0.8.0)
3030
msgpack (>= 1.3.1, < 2.0.0)
3131
serverengine (>= 2.2.2, < 3.0.0)
3232
sigdump (~> 0.2.2)
33-
strptime (>= 0.2.2, < 1.0.0)
33+
strptime (>= 0.2.4, < 1.0.0)
3434
tzinfo (>= 1.0, < 3.0)
3535
tzinfo-data (~> 1.0)
3636
webrick (>= 1.4.2, < 1.8.0)
@@ -48,19 +48,19 @@ GEM
4848
http-parser (1.2.3)
4949
ffi-compiler (>= 1.0, < 2.0)
5050
http_parser.rb (0.7.0)
51-
json (2.5.1)
51+
json (2.6.1)
5252
kubeclient (4.6.0)
5353
http (>= 3.0, < 5.0)
5454
recursive-open-struct (~> 1.0, >= 1.0.4)
5555
rest-client (~> 2.0)
5656
mime-types (3.3.1)
5757
mime-types-data (~> 3.2015)
58-
mime-types-data (3.2021.0704)
58+
mime-types-data (3.2021.0901)
5959
msgpack (1.4.2)
6060
multi_json (1.14.1)
6161
netrc (0.11.0)
6262
oj (3.10.18)
63-
power_assert (2.0.0)
63+
power_assert (2.0.1)
6464
public_suffix (4.0.6)
6565
rake (13.0.6)
6666
recursive-open-struct (1.1.3)
@@ -83,11 +83,11 @@ GEM
8383
power_assert
8484
tzinfo (2.0.4)
8585
concurrent-ruby (~> 1.0)
86-
tzinfo-data (1.2021.1)
86+
tzinfo-data (1.2021.5)
8787
tzinfo (>= 1.0.0)
8888
unf (0.1.4)
8989
unf_ext
90-
unf_ext (0.0.7.7)
90+
unf_ext (0.0.8)
9191
webmock (3.5.1)
9292
addressable (>= 2.3.6)
9393
crack (>= 0.3.2)
@@ -107,4 +107,4 @@ DEPENDENCIES
107107
webmock (~> 3.5.1)
108108

109109
BUNDLED WITH
110-
2.1.4
110+
2.2.23

0 commit comments

Comments
 (0)