Skip to content

Commit 0cb204d

Browse files
authored
1.1.8 (#74)
1 parent 8221c9a commit 0cb204d

14 files changed

+318
-178
lines changed

.circleci/config.yml

-87
This file was deleted.

.circleci/trigger_func_test.sh

-42
This file was deleted.

.github/workflows/ci_build_test.yaml

+192
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-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
- name: Setup Ruby and install gems
17+
uses: ruby/setup-ruby@v1
18+
with:
19+
bundler-cache: true
20+
ruby-version: 2.6
21+
22+
- name: Install dependencies
23+
run: |
24+
sudo ci_scripts/install_dep.sh
25+
26+
- name: Builder
27+
run: |
28+
rake build -t -v
29+
cp -R pkg /tmp
30+
31+
- name: Cache pkg
32+
uses: actions/cache@v1
33+
with:
34+
path: /tmp
35+
key: ${{ runner.os }}-build
36+
37+
unit-test:
38+
runs-on: ubuntu-latest
39+
needs:
40+
- build
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v2
44+
45+
- name: Install dependencies
46+
run: |
47+
sudo ci_scripts/install_dep.sh
48+
49+
- uses: actions/cache@v2
50+
with:
51+
path: /tmp
52+
key: ${{ runner.os }}-build
53+
54+
- name: Run unit tests
55+
run: |
56+
bundle exec rake test -t -v
57+
58+
func-test:
59+
needs:
60+
- unit-test
61+
runs-on: ubuntu-20.04
62+
env:
63+
CI_SPLUNK_PORT: 8089
64+
CI_SPLUNK_USERNAME: admin
65+
CI_SPLUNK_HEC_TOKEN: a6b5e77f-d5f6-415a-bd43-930cecb12959
66+
CI_SPLUNK_PASSWORD: helloworld
67+
CI_INDEX_EVENTS: ci_events
68+
CI_INDEX_OBJECTS: ci_objects
69+
CI_INDEX_METRICS: ci_metrics
70+
KUBERNETES_VERSION: v1.15.2
71+
MINIKUBE_VERSION: v1.21.0
72+
GITHUB_ACTIONS: true
73+
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v2
77+
78+
- name: Prepare container build
79+
id: prep
80+
run: |
81+
VERSION=`cat VERSION`
82+
TAGS=splunk/kube-objects:recent
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 kube-objects 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

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
docker/licenses/
1414
docker/gem/
1515
docker/gems/
16-
docker/.bundle/
16+
docker/.bundle/
17+
.idea/

0 commit comments

Comments
 (0)