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

1.1.7 #100

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions .circleci/config.yml

This file was deleted.

42 changes: 0 additions & 42 deletions .circleci/trigger_func_test.sh

This file was deleted.

192 changes: 192 additions & 0 deletions .github/workflows/ci_build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
name: CI Build Test

on:
pull_request:
branches-ignore:
- /^release\/.*/
- main

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Ruby 2.6.1
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6.1

- name: Install dependencies
run: |
sudo ci_scripts/install_dep.sh

- name: Builder
run: |
rake build -t -v
cp -R pkg /tmp

- name: Cache pkg
uses: actions/cache@v1
with:
path: /tmp
key: ${{ runner.os }}-build

unit-test:
runs-on: ubuntu-20.04
needs:
- build
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo ci_scripts/install_dep.sh

- uses: actions/cache@v2
with:
path: /tmp
key: ${{ runner.os }}-build

- name: Run unit tests
run: |
bundle exec rake test -t -v

func-test:
needs:
- unit-test
runs-on: ubuntu-20.04
env:
CI_SPLUNK_PORT: 8089
CI_SPLUNK_USERNAME: admin
CI_SPLUNK_HEC_TOKEN: a6b5e77f-d5f6-415a-bd43-930cecb12959
CI_SPLUNK_PASSWORD: helloworld
CI_INDEX_EVENTS: ci_events
CI_INDEX_OBJECTS: ci_objects
CI_INDEX_METRICS: ci_metrics
KUBERNETES_VERSION: v1.15.2
MINIKUBE_VERSION: v1.21.0
GITHUB_ACTIONS: true

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare container build
id: prep
run: |
VERSION=`cat VERSION`
TAGS=splunk/k8s-metrics:recent

echo ::set-output name=tags::${TAGS}
echo ::set-output name=version::${VERSION}

- name: Set up QEMU
uses: docker/setup-qemu-action@master
with:
platforms: all

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Build multi-arch kubernetes-metrics image
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./docker/Dockerfile
platforms: linux/amd64
push: false
load: true
tags: ${{ steps.prep.outputs.tags }}
build-args: VERSION=${{ steps.prep.outputs.version }}

- name: Check kubernetes-metrics image
run: |
docker image ls

- name: Setup Minikube
run: |
# Install Kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
mkdir -p ${HOME}/.kube
touch ${HOME}/.kube/config
# Install Minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
chmod +x minikube
sudo mv minikube /usr/local/bin/
# Start Minikube and Wait
minikube start --driver=docker --container-runtime=docker --cpus 2 --memory 4096 --kubernetes-version=${KUBERNETES_VERSION} --no-vtx-check
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
sleep 1;
done

- 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
# Wait until splunk is ready
until kubectl logs splunk --tail=2 | grep -q 'Ansible playbook complete'; do
sleep 1;
done
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
# Setup Indexes
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
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
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
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
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
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
# Enable HEC services
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
# Create new HEC token
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
# Restart Splunk
curl -k -u $CI_SPLUNK_USERNAME:$CI_SPLUNK_PASSWORD https://$CI_SPLUNK_HOST:$CI_SPLUNK_PORT/services/server/control/restart -X POST

- name: Deploy k8s connector
run: |
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
ci_scripts/deploy_connector.sh

- name: Deploy log generator
run: |
cd /opt/splunk-connect-for-kubernetes
kubectl apply -f test/test_setup.yaml
sleep 60

- uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Run functional tests
run: |
echo "check the pods"
kubectl get pods -A
cd /opt/splunk-connect-for-kubernetes
kubectl get nodes
export PYTHONWARNINGS="ignore:Unverified HTTPS request"
export CI_SPLUNK_HOST=$(kubectl get pod splunk --template={{.status.podIP}})
cd test
pip install --upgrade pip
pip install -r requirements.txt
echo "Running functional tests....."
python -m pytest \
--splunkd-url https://$CI_SPLUNK_HOST:8089 \
--splunk-user admin \
--splunk-password $CI_SPLUNK_PASSWORD \
-p no:warnings -s
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fluent-plugin-kubernetes-metrics (1.1.6)
fluent-plugin-kubernetes-metrics (1.1.7)
fluentd (>= 1.9.1)
kubeclient (~> 4.6.0)
multi_json (~> 1.14.1)
Expand All @@ -19,18 +19,18 @@ GEM
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ffi (1.15.3)
ffi (1.15.4)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
fluentd (1.13.2)
fluentd (1.14.2)
bundler
cool.io (>= 1.4.5, < 2.0.0)
http_parser.rb (>= 0.5.1, < 0.8.0)
msgpack (>= 1.3.1, < 2.0.0)
serverengine (>= 2.2.2, < 3.0.0)
sigdump (~> 0.2.2)
strptime (>= 0.2.2, < 1.0.0)
strptime (>= 0.2.4, < 1.0.0)
tzinfo (>= 1.0, < 3.0)
tzinfo-data (~> 1.0)
webrick (>= 1.4.2, < 1.8.0)
Expand All @@ -48,19 +48,19 @@ GEM
http-parser (1.2.3)
ffi-compiler (>= 1.0, < 2.0)
http_parser.rb (0.7.0)
json (2.5.1)
json (2.6.1)
kubeclient (4.6.0)
http (>= 3.0, < 5.0)
recursive-open-struct (~> 1.0, >= 1.0.4)
rest-client (~> 2.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0704)
mime-types-data (3.2021.0901)
msgpack (1.4.2)
multi_json (1.14.1)
netrc (0.11.0)
oj (3.10.18)
power_assert (2.0.0)
power_assert (2.0.1)
public_suffix (4.0.6)
rake (13.0.6)
recursive-open-struct (1.1.3)
Expand All @@ -83,11 +83,11 @@ GEM
power_assert
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2021.1)
tzinfo-data (1.2021.5)
tzinfo (>= 1.0.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unf_ext (0.0.8)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand All @@ -107,4 +107,4 @@ DEPENDENCIES
webmock (~> 3.5.1)

BUNDLED WITH
2.1.4
2.2.23
Loading