diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..9b88da7aceba033cad3446d825a83c988fddb557 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,132 @@ +image: gitlab-registry.cern.ch/linuxsupport/alma9-base + +stages: + - lint + - test + - build + - tag + - release + +docs_lint: + stage: lint + script: + - dnf install -y python-pip + - python3 -m pip install linkcheckmd + - python3 -m linkcheckmd -v README.md + +yaml_lint: + stage: lint + script: + - dnf install -y epel-release + - dnf install -y yamllint + - yamllint . + +helm_lint: + stage: lint + image: alpine/helm + script: + - helm dep update . + - helm lint --strict . + +version_test: + stage: test + rules: + - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "qa"' + script: | + dnf install -y python3-pip + pip install yq + MASTER_VERSION=$(curl https://gitlab.cern.ch/monitoring/helm-charts/kubernetes-monitoring/-/raw/qa/Chart.yaml?ref_type=heads | yq .version) + LOCAL_VERSION=$(cat Chart.yaml | yq .version) + if [ $MASTER_VERSION == $LOCAL_VERSION ]; then + echo "Please, update Chart.yaml version before merge." + exit -1 + else + echo "Chart version changed from $MASTER_VERSION to $LOCAL_VERSION." + fi + +helm_test: + stage: test + rules: + - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"' + script: | + dnf install -y python3-pip + pip install yq + dnf install -y python3-setuptools + dnf install -y gcc + dnf install -y python3-devel + dnf install -y epel-release + dnf install -y diffutils wget tar + wget https://get.helm.sh/helm-v3.15.3-linux-386.tar.gz + tar -zxvf helm-v3.15.3-linux-386.tar.gz + mv linux-386/helm /usr/local/bin/helm + rm helm-v3.15.3-linux-386.tar.gz + rm -rf linux-386 + + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + rm kubectl + + pip install python-openstackclient + pip install python-magnumclient + dnf install openssl + + export OS_AUTH_URL=$CI_OS_AUTH_URL + export OS_PROJECT_ID=$CI_OS_PROJECT_ID + export OS_PROJECT_NAME=$CI_OS_PROJECT_NAME + export OS_USER_DOMAIN_NAME=$CI_OS_USER_DOMAIN_NAME + export OS_USERNAME=$CI_OS_USERNAME + export OS_PASSWORD=$CI_OS_PASSWORD + export OS_REGION_NAME=$CI_OS_REGION_NAME + export OS_INTERFACE=$CI_OS_INTERFACE + export OS_IDENTITY_API_VERSION=$CI_OS_IDENTITY_API_VERSION + + echo "OpenStack configured as:" + echo "OS_AUTH_URL $OS_AUTH_URL" + echo "OS_PROJECT_ID $OS_PROJECT_ID" + echo "OS_PROJECT_NAME $OS_PROJECT_NAME" + echo "OS_USER_DOMAIN_NAME $OS_USER_DOMAIN_NAME" + echo "OS_USERNAME $OS_USERNAME" + echo "OS_PASSWORD $OS_PASSWORD" + echo "OS_REGION_NAME $OS_REGION_NAME" + echo "OS_INTERFACE $OS_INTERFACE" + echo "OS_IDENTITY_API_VERSION $OS_IDENTITY_API_VERSION" + + CLUSTER_NAME=test-cluster-$(openssl rand -hex 2) + echo "Creating cluster $CLUSTER_NAME..." + + openstack coe cluster create \ + --cluster-template kubernetes-1.30.2-1 \ + --node-count 1 \ + --flavor m2.medium \ + --merge-labels \ + --labels eos_enabled=false \ + --labels cern_enabled=false \ + $CLUSTER_NAME + sleep 10 + + + STATUS=$(openstack coe cluster show $CLUSTER_NAME -c status -f value) + while [ "${STATUS}" != "CREATE_COMPLETE" ] && [ "${STATUS}" != "CREATE_FAILED" ] + do + STATUS=$(openstack coe cluster show $CLUSTER_NAME -c status -f value) + echo "Current cluster status ... $STATUS $(date)" + sleep 10 + done + + echo "Cluster $CLUSTER_NAME CREATED. Configuring credentials." + openstack coe cluster config --force $CLUSTER_NAME 2> /dev/null || true + echo "Exporting Kubeconfig..." + export KUBECONFIG=$(pwd)/config + + echo "Installing and testing helm chart" + LOCAL_VERSION=$(cat Chart.yaml | yq -r .version) + kubectl delete -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml || true + helm dependency update + helm package . + ls -all + helm install cern-it-kubernetes-monitoring-crds https://gitlab.cern.ch/monitoring/helm-charts/kubernetes-monitoring-crds/-/archive/v0.1.0/kubernetes-monitoring-crds-v0.1.0.tar.gz -n monitoring --create-namespace + helm install cern-it-kubernetes-monitoring ./cern-it-kubernetes-monitoring-$LOCAL_VERSION.tgz -f values.yaml -n monitoring --create-namespace + helm test --logs cern-it-kubernetes-monitoring -n monitoring + + echo "Deleting temporal cluster." + openstack coe cluster delete $CLUSTER_NAME diff --git a/.helmignore b/.helmignore index 0e8a0eb36f4ca2c939201c0d54b5d82a1ea34778..df65d1087ee2367ca1d075fa9076635836ae0dff 100644 --- a/.helmignore +++ b/.helmignore @@ -4,6 +4,12 @@ .DS_Store # Common VCS dirs .git/ +.gitlab-ci-local/ +.gitlab-ci.yml +.helmignore +.yamllint +config +README.md .gitignore .bzr/ .bzrignore @@ -21,3 +27,4 @@ .idea/ *.tmproj .vscode/ +config \ No newline at end of file diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000000000000000000000000000000000000..0fe8361fb471006d24f9a7fe1af03b514c734e22 --- /dev/null +++ b/.yamllint @@ -0,0 +1,6 @@ +rules: + line-length: disable + indentation: + spaces: 2 +ignore: + - templates/* diff --git a/Chart.yaml b/Chart.yaml index 8275f9b67841050e5d75afabd0ee02118d741ddf..dfb492ba444e161a6d3585054b23d6a15d507acb 100644 --- a/Chart.yaml +++ b/Chart.yaml @@ -1,14 +1,7 @@ apiVersion: v2 -name: cern-it-monitoring-kubernetes +name: cern-it-kubernetes-monitoring type: application -appVersion: v0.1.0 -version: 0.1.0 +version: 0.1.1 kubeVersion: ">=1.27.0-0" description: Helm Chart provided by IT Monitoring Service to install and configure required components to gather and send monitoring data from kubernetes clusters to central service. home: https://cern.ch/monitoring -dependencies: - - name: metrics-server - repository: https://kubernetes-sigs.github.io/metrics-server/ - version: 3.12.1 - alias: metricsserver - condition: metrics.metricsserver.enabled diff --git a/values.yaml b/values.yaml index 0dde155b6f8444931c18c4a7446e4d36e43c6511..485a67748679d5e36486093bab6837cc85b5f4eb 100644 --- a/values.yaml +++ b/values.yaml @@ -18,21 +18,6 @@ kubernetes: # -- name of the kubernetes cluster to monitor. This value will be appended to very metric and log via k8sClusterName label clusterName: nil - -# Metrics server specific confiuration. -# This goes outside of metrics since it uses an external chart -metricsserver: - # -- if true metrics server will be installed - enabled: false - nodeSelector: {} - resources: - requests: - cpu: "100m" - memory: "200Mi" - limits: - cpu: "100m" - memory: "200Mi" - # The metrics section includes all the components meant to produce, scrape, # collect or forward metrics. You can configure all components independently. metrics: @@ -200,11 +185,11 @@ logs: scrapeInterval: "15s" resources: requests: - cpu: "5m" - memory: "15Mi" + cpu: "5m" + memory: "15Mi" limits: - cpu: "20m" - memory: "25Mi" + cpu: "20m" + memory: "25Mi" # -- fluentbit service configuration options in a multiline string service: | @@ -269,7 +254,7 @@ logs: add_label k8s_cluster_name {{ .Values.kubernetes.clusterName }} host {{ .Values.otlp.endpoint }} port {{ .Values.otlp.port }} - metrics_uri: /v1/metrics + metrics_uri /v1/metrics logs_uri /v1/logs traces_uri /v1/traces tls on