Skip to content

Commit

Permalink
Merge pull request #1385 from mrueg/release-1.9-bp
Browse files Browse the repository at this point in the history
Backports to 1.9 for new 1.9.8 release
  • Loading branch information
k8s-ci-robot authored Feb 19, 2021
2 parents 89aaf6c + c93845e commit 3cb32d8
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 120 deletions.
197 changes: 197 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: continuous-integration

on:
push:
branches:
- master
- release*
tags:
- v1.*
- v2.*
pull_request:
branches:
- master
- release*

env:
E2E_SETUP_KIND: yes
E2E_SETUP_KUBECTL: yes
SUDO: sudo

jobs:
ci-go-lint:
name: ci-go-lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Lint
run: |
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.30.0
make lint
ci-validate-manifests:
name: ci-validate-manifests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Validate generated manifests
run: |
make validate-manifests
ci-validate-go-modules:
name: ci-validate-go-modules
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Validate vendor is in sync with go modules
run: |
make validate-modules
ci-validate-docs:
name: ci-validate-docs
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Check that all metrics are documented
run: |
make doccheck
ci-unit-tests:
name: ci-unit-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Unit tests
run: |
make test-unit
ci-benchmark-tests:
name: ci-benchmark-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Benchmark tests
run: |
make test-benchmark-compare
ci-build-kube-state-metrics:
name: ci-build-kube-state-metrics
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: Build
run: |
make build
ci-e2e-tests:
name: ci-e2e-tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Setup environment
run: |
go get -v -t -d ./...
make install-tools
- name: End-to-end tests
run: |
REGISTRY="quay.io/coreos" make e2e
50 changes: 0 additions & 50 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.13 as builder
ARG GOVERSION=1.15
FROM golang:${GOVERSION} as builder
ARG GOARCH
ENV GOARCH=${GOARCH}
WORKDIR /go/src/k8s.io/kube-state-metrics/
Expand Down
27 changes: 10 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@ TESTENVVAR =
REGISTRY ?= gcr.io/k8s-staging-kube-state-metrics
TAG_PREFIX = v
VERSION = $(shell cat VERSION)
TAG = $(TAG_PREFIX)$(VERSION)
TAG ?= $(TAG_PREFIX)$(VERSION)
LATEST_RELEASE_BRANCH := release-$(shell grep -ohE "[0-9]+.[0-9]+" VERSION)
DOCKER_CLI ?= docker
PKGS = $(shell go list ./... | grep -v /vendor/ | grep -v /tests/e2e)
ARCH ?= $(shell go env GOARCH)
BuildDate = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
Commit = $(shell git rev-parse --short HEAD)
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
ALL_ARCH = amd64 arm arm64 ppc64le s390x
PKG = k8s.io/kube-state-metrics/pkg
GO_VERSION = 1.13
FIRST_GOPATH := $(firstword $(subst :, ,$(shell go env GOPATH)))
BENCHCMP_BINARY := $(FIRST_GOPATH)/bin/benchcmp
GOLANGCI_VERSION := v1.19.1
HAS_GOLANGCI := $(shell which golangci-lint)

GO_VERSION = 1.15.7
IMAGE = $(REGISTRY)/kube-state-metrics
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)

Expand All @@ -43,9 +38,6 @@ licensecheck:
fi

lint: shellcheck licensecheck
ifndef HAS_GOLANGCI
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin ${GOLANGCI_VERSION}
endif
golangci-lint run

doccheck: generate
Expand All @@ -62,7 +54,7 @@ doccheck: generate
@echo OK

build-local:
GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-s -w -X ${PKG}/version.Release=${TAG} -X ${PKG}/version.Commit=${Commit} -X ${PKG}/version.BuildDate=${BuildDate}" -o kube-state-metrics
GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-s -w -X ${PKG}/version.Release=${TAG} -X ${PKG}/version.Commit=${GIT_COMMIT} -X ${PKG}/version.BuildDate=${BUILD_DATE}" -o kube-state-metrics

build: kube-state-metrics

Expand All @@ -77,7 +69,8 @@ shellcheck:

# Runs benchmark tests on the current git ref and the last release and compares
# the two.
test-benchmark-compare: $(BENCHCMP_BINARY)
test-benchmark-compare:
@git fetch
./tests/compare_benchmarks.sh master
./tests/compare_benchmarks.sh ${LATEST_RELEASE_BRANCH}

Expand All @@ -88,7 +81,7 @@ all: all-container
container: container-$(ARCH)

container-%:
${DOCKER_CLI} build --pull -t $(IMAGE)-$*:$(TAG) --build-arg GOARCH=$* .
${DOCKER_CLI} build --pull -t $(IMAGE)-$*:$(TAG) --build-arg GOVERSION=$(GO_VERSION) --build-arg GOARCH=$* .

sub-container-%:
$(MAKE) --no-print-directory ARCH=$* container
Expand All @@ -106,7 +99,7 @@ do-push-%:

push-multi-arch:
${DOCKER_CLI} manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g")
@for arch in $(ALL_ARCH); do ${DOCKER_CLI} manifest annotate --arch $${arch} $(IMAGE):$(TAG) $(IMAGE)-$${arch}:${TAG}; done
@for arch in $(ALL_ARCH); do ${DOCKER_CLI} manifest annotate --arch $${arch} $(IMAGE):$(TAG) $(IMAGE)-$${arch}:$(TAG); done
${DOCKER_CLI} manifest push --purge $(IMAGE):$(TAG)

quay-push: .quay-push-$(ARCH)
Expand All @@ -128,7 +121,7 @@ e2e:
generate: build-local
@echo ">> generating docs"
@./scripts/generate-help-text.sh
@$(GOPATH)/bin/embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print`
embedmd -w `find . -path ./vendor -prune -o -name "*.md" -print`

validate-manifests: examples
@git diff --exit-code
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Overview

[![Build Status](https://travis-ci.org/kubernetes/kube-state-metrics.svg?branch=master)](https://travis-ci.org/kubernetes/kube-state-metrics) [![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![GoDoc](https://godoc.org/github.com/kubernetes/kube-state-metrics?status.svg)](https://godoc.org/github.com/kubernetes/kube-state-metrics)
[![Build Status](https://github.com/kubernetes/kube-state-metrics/workflows/continuous-integration/badge.svg)](https://github.com/kubernetes/kube-state-metrics/actions)
[![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes/kube-state-metrics)](https://goreportcard.com/report/github.com/kubernetes/kube-state-metrics) [![GoDoc](https://godoc.org/github.com/kubernetes/kube-state-metrics?status.svg)](https://godoc.org/github.com/kubernetes/kube-state-metrics)

kube-state-metrics is a simple service that listens to the Kubernetes API
server and generates metrics about the state of the objects. (See examples in
Expand Down
2 changes: 1 addition & 1 deletion cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ steps:
- name: 'gcr.io/k8s-testimages/gcb-docker-gcloud:v20190906-745fed4'
entrypoint: make
env:
- GIT_TAG=$_PULL_BASE_REF
- TAG=$_PULL_BASE_REF
- GIT_COMMIT=$_PULL_BASE_SHA
args:
- push
2 changes: 1 addition & 1 deletion pkg/metricshandler/metrics_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (m *MetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}

for _, s := range m.stores {
s.WriteAll(w)
s.WriteAll(writer)
}

// In case we gzipped the response, we have to close the writer.
Expand Down
7 changes: 3 additions & 4 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# End2end testsuite

This folder contains simple e2e tests.
When launched it spins up a kubernetes cluster using minikube, creates several kubernetes resources and launches a kube-state-metrics deployment.
Then, it downloads kube-state-metrics' metrics and examines validity using `promtool` tool.
When launched, it spins up a kubernetes cluster using [kind](https://kind.sigs.k8s.io/), creates several kubernetes resources and launches a kube-state-metrics deployment.
Then, it runs verification tests: check metrics' presence, lint metrics, check service health, etc.

The testsuite is run automatically using Travis.
The test suite is run automatically using Github Actions.

## Running locally

To run the e2e tests locally run the following command:

```bash
export MINIKUBE_DRIVER=virtualbox # choose minikube's driver of your choice
./tests/e2e.sh
```
Loading

0 comments on commit 3cb32d8

Please sign in to comment.