Skip to content

Commit

Permalink
Implement CI using CircleCI (#421)
Browse files Browse the repository at this point in the history
* Implement CI using Circleci

* Modify config.yaml and add missing new line

* Add build require in tests workflow

* Update crds in ci_test.sh

* Fix path of crd template

* Update env for disabling log rules in obsctl reloader

* Update prometheus-operator crd link

* Incorporate review comments

* Add check for restartCount in run_test

* Update go version
  • Loading branch information
vprashar2929 authored Apr 5, 2023
1 parent 38b06ef commit 0b24e59
Show file tree
Hide file tree
Showing 12 changed files with 733 additions and 15 deletions.
71 changes: 71 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
version: 2.1
jobs:
build:
docker:
- image: cimg/go:1.19
steps:
- checkout
- run: make vendor_jsonnet
- run: make grafana manifests prometheusrules
- run: make format
- run: make lint
- run: make validate
- run: git diff --exit-code
tests:
machine:
image: ubuntu-2004:current
resource_class: large
environment:
KUBECONFIG: kubeconfig
steps:
- checkout
- run:
name: Get dependicies
command: |
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
wget \
gnupg \
lsb-release
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
- run:
name: Install Docker
command: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- run:
name: Get OC CLI Binary
command: |
wget https://github.com/okd-project/okd/releases/download/4.12.0-0.okd-2023-02-18-033438/openshift-client-linux-4.12.0-0.okd-2023-02-18-033438.tar.gz
tar xzvf openshift-client-linux-4.12.0-0.okd-2023-02-18-033438.tar.gz
sudo mv oc kubectl /usr/local/bin
- run:
name: Spin up microshift container
command: |
docker run -d --name microshift --privileged -v microshift-data:/var/lib -p 6443:6443 -p 80:80 -p 443:443 quay.io/microshift/microshift-aio:latest
sleep 60
- run:
name: Export the kubeconfig
command: docker exec -i microshift cat /var/lib/microshift/resources/kubeadmin/kubeconfig > tests/ci/kubeconfig
- run:
name: Run tests
command: |
echo $KUBECONFIG
cd tests/ci
./ci_test.sh metrics
- store_artifacts:
path: /tmp/artifacts
workflows:
version: 2
build-and-test:
jobs:
- build
- tests:
requires:
- build
34 changes: 23 additions & 11 deletions resources/services/observatorium-metrics-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ objects:
periodSeconds: 30
resources:
limits:
cpu: "4"
memory: 4Gi
cpu: ${OBSERVATORIUM_ALERTMANAGER_CPU_LIMIT}
memory: ${OBSERVATORIUM_ALERTMANAGER_MEMORY_LIMIT}
requests:
cpu: "1"
memory: 1Gi
cpu: ${OBSERVATORIUM_ALERTMANAGER_CPU_REQUEST}
memory: ${OBSERVATORIUM_ALERTMANAGER_MEMORY_REQUEST}
volumeMounts:
- mountPath: /data
name: alertmanager-data
Expand Down Expand Up @@ -435,7 +435,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storage: ${OBSERVATORIUM_ALERTMANAGER_PVC_STORAGE}
- apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -3109,7 +3109,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -3366,7 +3366,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -3623,7 +3623,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -3880,7 +3880,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -4137,7 +4137,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: v1
kind: Service
Expand Down Expand Up @@ -4394,7 +4394,7 @@ objects:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storage: ${THANOS_STORE_PVC_STORAGE}
storageClassName: ${STORAGE_CLASS}
- apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
Expand Down Expand Up @@ -4478,6 +4478,16 @@ parameters:
value: quay.io/prometheus/alertmanager
- name: OBSERVATORIUM_ALERTMANAGER_IMAGE_TAG
value: v0.25.0
- name: OBSERVATORIUM_ALERTMANAGER_PVC_STORAGE
value: 10Gi
- name: OBSERVATORIUM_ALERTMANAGER_CPU_REQUEST
value: "1"
- name: OBSERVATORIUM_ALERTMANAGER_MEMORY_REQUEST
value: 1Gi
- name: OBSERVATORIUM_ALERTMANAGER_MEMORY_LIMIT
value: "4"
- name: OBSERVATORIUM_ALERTMANAGER_CPU_LIMIT
value: 4Gi
- name: SERVICE_ACCOUNT_NAME
value: prometheus-telemeter
- name: STORAGE_CLASS
Expand Down Expand Up @@ -4644,6 +4654,8 @@ parameters:
value: "2"
- name: THANOS_STORE_CPU_REQUEST
value: 500m
- name: THANOS_STORE_PVC_STORAGE
value: 50Gi
- name: THANOS_STORE_SERIES_TOUCHED_LIMIT
value: "0"
- name: THANOS_STORE_SERIES_SAMPLE_LIMIT
Expand Down
6 changes: 6 additions & 0 deletions services/observatorium-metrics-template.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ local obs = import 'observatorium.libsonnet';
{ name: 'OBSERVATORIUM_ALERTMANAGER_LOG_LEVEL', value: 'info' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_IMAGE', value: 'quay.io/prometheus/alertmanager' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_IMAGE_TAG', value: 'v0.25.0' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_PVC_STORAGE', value: '10Gi' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_CPU_REQUEST', value: '1' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_MEMORY_REQUEST', value: '1Gi' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_MEMORY_LIMIT', value: '4' },
{ name: 'OBSERVATORIUM_ALERTMANAGER_CPU_LIMIT', value: '4Gi' },
{ name: 'SERVICE_ACCOUNT_NAME', value: 'prometheus-telemeter' },
{ name: 'STORAGE_CLASS', value: 'gp2-csi' },
{ name: 'THANOS_COMPACTOR_CPU_LIMIT', value: '1' },
Expand Down Expand Up @@ -124,6 +129,7 @@ local obs = import 'observatorium.libsonnet';
{ name: 'THANOS_STORE_BUCKET_CACHE_REPLICAS', value: '3' },
{ name: 'THANOS_STORE_CPU_LIMIT', value: '2' },
{ name: 'THANOS_STORE_CPU_REQUEST', value: '500m' },
{ name: 'THANOS_STORE_PVC_STORAGE', value: '50Gi' },
{ name: 'THANOS_STORE_SERIES_TOUCHED_LIMIT', value: '0' },
{ name: 'THANOS_STORE_SERIES_SAMPLE_LIMIT', value: '0' },
{ name: 'THANOS_STORE_INDEX_CACHE_CONNECTION_LIMIT', value: '3072' },
Expand Down
8 changes: 4 additions & 4 deletions services/observatorium-metrics.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ local oauthProxy = import './sidecars/oauth-proxy.libsonnet';
storageClassName: '${STORAGE_CLASS}',
resources: {
requests: {
storage: '50Gi',
storage: '${THANOS_STORE_PVC_STORAGE}',
},
},
},
Expand Down Expand Up @@ -926,7 +926,7 @@ local oauthProxy = import './sidecars/oauth-proxy.libsonnet';
accessModes: ['ReadWriteOnce'],
resources: {
requests: {
storage: '10Gi',
storage: '${OBSERVATORIUM_ALERTMANAGER_PVC_STORAGE}',
},
},
},
Expand Down Expand Up @@ -985,8 +985,8 @@ local oauthProxy = import './sidecars/oauth-proxy.libsonnet';
path: '/',
} },
resources: {
requests: { cpu: '1', memory: '1Gi' },
limits: { cpu: '4', memory: '4Gi' },
requests: { cpu: '${OBSERVATORIUM_ALERTMANAGER_CPU_REQUEST}', memory: '${OBSERVATORIUM_ALERTMANAGER_MEMORY_REQUEST}' },
limits: { cpu: '${OBSERVATORIUM_ALERTMANAGER_CPU_LIMIT}', memory: '${OBSERVATORIUM_ALERTMANAGER_MEMORY_LIMIT}' },
},
}],
volumes: [
Expand Down
Loading

0 comments on commit 0b24e59

Please sign in to comment.