Skip to content

Commit b2c6ce5

Browse files
authoredAug 31, 2020
Merge pull request #8 from OT-CONTAINER-KIT/code-refactor
[Development][Add] Added Circle CI config
2 parents 51cce97 + 838ac3d commit b2c6ce5

File tree

3 files changed

+124
-2
lines changed

3 files changed

+124
-2
lines changed
 

‎.circleci/config.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
version: 2
3+
jobs:
4+
code-quality:
5+
docker:
6+
- image: circleci/golang:1.13
7+
working_directory: /go/src/logging-operator
8+
steps:
9+
- checkout
10+
- run: make fmt
11+
- run: make vet
12+
13+
code-build:
14+
docker:
15+
- image: circleci/golang:1.13
16+
working_directory: /go/src/logging-operator
17+
steps:
18+
- checkout
19+
- run: make manager
20+
21+
image-build:
22+
docker:
23+
- image: circleci/golang:1.13
24+
working_directory: /go/src/logging-operator
25+
steps:
26+
- checkout
27+
- setup_remote_docker
28+
- run: make bundle-build
29+
30+
k8s-validation:
31+
machine:
32+
image: circleci/classic:201808-01
33+
environment:
34+
K8S_VERSION: v1.15.7
35+
HELM_VERSION: v3.1.0
36+
KUBECONFIG: /home/circleci/.kube/config
37+
MINIKUBE_VERSION: v1.7.3
38+
MINIKUBE_WANTUPDATENOTIFICATION: false
39+
MINIKUBE_WANTREPORTERRORPROMPT: false
40+
MINIKUBE_HOME: /home/circleci
41+
CHANGE_MINIKUBE_NONE_USER: true
42+
steps:
43+
- checkout
44+
- run:
45+
name: Setup kubectl
46+
command: |
47+
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
48+
mkdir -p ${HOME}/.kube
49+
touch ${HOME}/.kube/config
50+
- run:
51+
name: Setup minikube
52+
command: |
53+
curl -Lo minikube https://github.com/kubernetes/minikube/releases/download/${MINIKUBE_VERSION}/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
54+
- run:
55+
name: Start minikube
56+
command: |
57+
sudo -E minikube start --vm-driver=none --cpus 2 --memory 2048 --kubernetes-version=${K8S_VERSION}
58+
- run:
59+
name: Setup helm
60+
command: |
61+
curl -Lo helm-${HELM_VERSION}-linux-amd64.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz \
62+
&& tar -xvzf helm-${HELM_VERSION}-linux-amd64.tar.gz && chmod +x linux-amd64/helm \
63+
&& sudo mv linux-amd64/helm /usr/local/bin/
64+
- run:
65+
name: Setup Namespace
66+
command: |
67+
kubectl create namespace logging-operator
68+
- run:
69+
name: Validating logging operator
70+
command: |
71+
./scripts/k8s-validate.sh
72+
73+
workflows:
74+
version: 2
75+
main:
76+
jobs:
77+
- code-quality
78+
- code-build
79+
- image-build
80+
- k8s-validation

‎Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ bundle: manifests
114114

115115
# Build the bundle image.
116116
bundle-build:
117-
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
117+
docker build -f Dockerfile -t $(BUNDLE_IMG) .
118118

119119
# Template the helm chart
120120
helm-template:
121121
cd helm-charts && helm template logging-operator ./
122122

123123
# Install using the helm chart
124-
helm-template:
124+
helm-install:
125125
cd helm-charts && helm upgrade logging-operator ./ -f values.yaml --namespace logging-operator --install

‎scripts/k8s-validate.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
lint_chart() {
4+
echo "--------------Linting Helm Chart--------------"
5+
helm lint ./helm-charts/logging-operator/
6+
}
7+
8+
deploy_chart() {
9+
echo "--------------Deploying Helm Chart--------------"
10+
helm upgrade logging-operator \
11+
./helm-charts/logging-operator/ \
12+
-f ./helm-charts/logging-operator/values.yaml \
13+
--namespace logging-operator --install
14+
}
15+
16+
validate_chart() {
17+
echo "--------------Testing Helm Chart--------------"
18+
helm test logging-operator --namespace logging-operator
19+
}
20+
21+
validate_container_state() {
22+
echo "--------------Validating Deployment Status--------------"
23+
output=$(kubectl get pods -n logging-operator -l app.kubernetes.io/name=logging-operator \
24+
-o jsonpath="{.items[*]['status.phase']}")
25+
if [ "${output}" != "Running" ] && [ "${output}" != "" ]
26+
then
27+
echo "Container is not healthy"
28+
exit 1
29+
else
30+
echo "Container is running fine"
31+
fi
32+
}
33+
34+
main_function() {
35+
lint_chart
36+
deploy_chart
37+
validate_chart
38+
sleep 30s
39+
validate_container_state
40+
}
41+
42+
main_function

0 commit comments

Comments
 (0)
Please sign in to comment.