This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from deislabs/grampelberg/scaffold
Implement metrics.smi-spec.io for Linkerd
- Loading branch information
Showing
37 changed files
with
2,732 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tmp | ||
*.yml | ||
*.yaml | ||
Makefile | ||
Tiltfile | ||
*.md | ||
chart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Output of swag generator | ||
pkg/docs | ||
|
||
tmp | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
linters: | ||
enable-all: true | ||
disable: | ||
- maligned | ||
- prealloc | ||
- gochecknoglobals | ||
|
||
skip-dirs: | ||
# ignore the system libraries | ||
- libexec/src/strings | ||
|
||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
golint: | ||
min-confidence: 0 | ||
gocyclo: | ||
min-complexity: 10 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
misspell: | ||
locale: US | ||
lll: | ||
line-length: 140 | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
gocritic: | ||
enabled-tags: | ||
- performance | ||
- style | ||
- experimental | ||
disabled-checks: | ||
- wrapperFunc | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- rangeValCopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM golang:1.12-alpine as builder | ||
ARG NETRC | ||
|
||
WORKDIR /src | ||
|
||
RUN apk add --no-cache \ | ||
git | ||
|
||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
RUN echo "${NETRC}" > ~/.netrc | ||
RUN go mod download | ||
|
||
COPY . . | ||
|
||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./cmd/smi-metrics/... | ||
|
||
FROM scratch | ||
|
||
WORKDIR /src | ||
|
||
COPY --from=builder /src/smi-metrics / | ||
|
||
CMD /smi-metrics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
|
||
HAS_TILT := $(shell command -v tilt;) | ||
|
||
TAG := $(shell git describe --exact-match --tags $(git log -n1 --pretty='%h')) | ||
|
||
IMAGE := thomasr/smi-metrics | ||
|
||
.PHONY: bootstrap | ||
bootstrap: | ||
@# Bootstrap the required binaries | ||
ifndef HAS_TILT | ||
echo "Install tilt from https://docs.tilt.dev/install.html" | ||
endif | ||
|
||
.PHONY: dev | ||
dev: bootstrap | ||
tilt up | ||
|
||
.PHONY: push | ||
push: build | ||
docker push $(IMAGE):$(TAG) | ||
|
||
.PHONY: build | ||
build: | ||
NETRC=$$(cat ~/.netrc) && \ | ||
docker build --build-arg NETRC -t $(IMAGE):$(TAG) . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
k8s_yaml(local("helm template chart -f dev.yaml --name dev")) | ||
watch_file('chart') | ||
|
||
docker_build('thomasr/smi-metrics', '.', build_args={ | ||
'NETRC': str(local('cat ~/.netrc')) | ||
}) | ||
|
||
k8s_resource('dev-smi-metrics', port_forwards=['8080:8080', '8081:8081']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh -x | ||
|
||
exit_script() { | ||
echo "Shutting down..." | ||
trap - EXIT HUP INT QUIT PIPE TERM # clear the trap | ||
kill -- -$$ # Sends SIGTERM to child/sub processes | ||
} | ||
|
||
trap exit_script EXIT HUP INT QUIT PIPE TERM | ||
|
||
echo "Sleeping. Pid=$$" | ||
sleep 2147483647 & | ||
|
||
# Install dev helpers | ||
apk add --no-cache \ | ||
alpine-sdk | ||
|
||
go mod download | ||
|
||
wait $! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
appVersion: "0.1" | ||
description: Provider for metrics.smi-spec.io | ||
name: smi-metrics | ||
version: 0.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "smi-metrics.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "smi-metrics.fullname" -}} | ||
{{- if .Values.fullnameOverride -}} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- if contains $name .Release.Name -}} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}} | ||
{{- else -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "smi-metrics.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- $cn := list (include "smi-metrics.fullname" .) .Release.Namespace "svc" | join "." -}} | ||
{{- $ca := genCA $cn 365 -}} | ||
{{- $cert := genSignedCert $cn nil nil 365 $ca -}} | ||
apiVersion: apiregistration.k8s.io/v1beta1 | ||
kind: APIService | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
name: v1alpha1.metrics.smi-spec.io | ||
spec: | ||
service: | ||
name: {{ include "smi-metrics.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
caBundle: {{ b64enc $ca.Cert }} | ||
group: metrics.smi-spec.io | ||
version: v1alpha1 | ||
insecureSkipTLSVerify: false | ||
groupPriorityMinimum: 100 | ||
versionPriority: 100 | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
name: {{ include "smi-metrics.fullname" . }} | ||
type: kubernetes.io/tls | ||
data: | ||
tls.crt: {{ b64enc $cert.Cert }} | ||
tls.key: {{ b64enc $cert.Key }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
name: {{ include "smi-metrics.fullname" . }} | ||
data: | ||
config.yml: | | ||
{{- .Values.config | toYaml | nindent 4 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "smi-metrics.fullname" . }} | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
spec: | ||
containers: | ||
- name: shim | ||
image: {{ .Values.image.name }} | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
|
||
command: | ||
- /smi-metrics | ||
- --config=/config.yml | ||
|
||
ports: | ||
- containerPort: 8080 | ||
name: api | ||
protocol: TCP | ||
- containerPort: 8081 | ||
name: admin | ||
protocol: TCP | ||
|
||
volumeMounts: | ||
- name: config | ||
mountPath: /config.yml | ||
subPath: config.yml | ||
- mountPath: /var/run/smi-metrics | ||
name: tls | ||
readOnly: true | ||
|
||
{{ if .Values.probes }} | ||
livenessProbe: | ||
httpGet: | ||
path: /status | ||
port: 8081 | ||
readinessProbe: | ||
httpGet: | ||
path: /status | ||
port: 8081 | ||
{{ end }} | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
|
||
volumes: | ||
- name: config | ||
configMap: | ||
name: {{ include "smi-metrics.fullname" . }} | ||
- name: tls | ||
secret: | ||
secretName: {{ include "smi-metrics.fullname" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
name: {{ include "smi-metrics.fullname" . }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
name: {{ include "smi-metrics.fullname" . }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: extension-apiserver-authentication-reader | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "smi-metrics.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "smi-metrics.fullname" . }} | ||
labels: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
helm.sh/chart: {{ include "smi-metrics.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
spec: | ||
ports: | ||
- port: 443 | ||
targetPort: api | ||
protocol: TCP | ||
selector: | ||
app.kubernetes.io/name: {{ include "smi-metrics.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} |
Oops, something went wrong.