Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #81 from ricardomaraschini/preparing-for-olm-release
Browse files Browse the repository at this point in the history
Preparing tagger to be deployed through OLM
  • Loading branch information
ricardomaraschini authored Aug 2, 2021
2 parents 1458f66 + 50e3386 commit 58265cd
Show file tree
Hide file tree
Showing 19 changed files with 686 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_output/
output/
.env
.git/
.gitignore
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
run: make kubectl-tag

- name: compress linux plugin
run: tar -C _output/bin -czvf kubectl-tag-linux-amd64.tgz kubectl-tag
run: tar -C output/bin -czvf kubectl-tag-linux-amd64.tgz kubectl-tag

- name: build darwin plugin
run: make kubectl-tag-darwin

- name: compress darwin plugin
run: tar -C _output/bin -czvf kubectl-tag-darwin-amd64.tgz kubectl-tag
run: tar -C output/bin -czvf kubectl-tag-darwin-amd64.tgz kubectl-tag

- name: build helm chart release
run: helm package chart/
Expand All @@ -45,4 +45,4 @@ jobs:
title: development release build
files: |
*.tgz
_output/doc/README.pdf
output/doc/README.pdf
6 changes: 3 additions & 3 deletions .github/workflows/stable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:
run: VERSION=${{ steps.get_tag.outputs.tag }} make kubectl-tag

- name: compress linux plugin
run: tar -C _output/bin -czvf kubectl-tag-linux-amd64.tgz kubectl-tag
run: tar -C output/bin -czvf kubectl-tag-linux-amd64.tgz kubectl-tag

- name: VERSION=${{ steps.get_tag.outputs.tag }} build darwin plugin
run: make kubectl-tag-darwin

- name: compress darwin plugin
run: tar -C _output/bin -czvf kubectl-tag-darwin-amd64.tgz kubectl-tag
run: tar -C output/bin -czvf kubectl-tag-darwin-amd64.tgz kubectl-tag

- name: setting version in values.yaml
run: sed -i 's/latest/${{ steps.get_tag.outputs.tag }}/g' chart/values.yaml
Expand All @@ -53,4 +53,4 @@ jobs:
prerelease: false
files: |
*.tgz
_output/doc/README.pdf
output/doc/README.pdf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_output
output
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN make tagger
#
FROM docker.io/fedora:latest
RUN dnf install -y device-mapper-libs
COPY --from=builder /src/_output/bin/tagger /usr/local/bin/tagger
COPY --from=builder /src/output/bin/tagger /usr/local/bin/tagger
# 8080 pod mutating webhook handler.
# 8081 quay webhooks handler.
# 8082 docker webhooks handler.
Expand Down
33 changes: 30 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@ PLUGIN = kubectl-tag
PLUGIN_DARWIN = kubectl-tag-darwin

VERSION ?= v0.0.0
BUNDLE_VERSION ?= 0.0.0
IMAGE_BUILDER ?= podman
BUNDLE_IMAGE ?= quay.io/tagger/olm-bundle
IMAGE ?= quay.io/tagger/operator
IMAGE_TAG = $(IMAGE):latest
BUNDLE_TAG = $(BUNDLE_IMAGE):latest

OUTPUT_DIR ?= _output
OUTPUT_DIR ?= output
OUTPUT_BIN = $(OUTPUT_DIR)/bin
OUTPUT_DOC = $(OUTPUT_DIR)/doc
OUTPUT_OLM_BUNDLE = $(OUTPUT_DIR)/bundle

TAGGER_BIN = $(OUTPUT_BIN)/$(APP)
PLUGIN_BIN = $(OUTPUT_BIN)/$(PLUGIN)
GEN_BIN = $(OUTPUT_DIR)/code-generator
OPERATOR_SDK_BIN = $(OUTPUT_DIR)/operator-sdk

PROJECT = github.com/ricardomaraschini/$(APP)
GEN_OUTPUT = /tmp/$(PROJECT)/infra/tags
OPERATOR_SDK_URL = https://github.com/operator-framework/operator-sdk/releases/download

default: build

Expand Down Expand Up @@ -52,14 +58,35 @@ get-code-generator:
https://github.com/kubernetes/code-generator.git \
$(GEN_BIN)

generate: generate-proto generate-k8s

.PHONY: generate-proto
generate-proto:
protoc --go-grpc_out=paths=source_relative:. \
--go_out=paths=source_relative:. \
./infra/pb/*.proto

.PHONY: get-operator-sdk
get-operator-sdk:
curl -L $(OPERATOR_SDK_URL)/v1.10.0/operator-sdk_linux_amd64 -o $(OPERATOR_SDK_BIN)
chmod 755 $(OPERATOR_SDK_BIN)

.PHONY: generate-bundle
generate-bundle:
$(OPERATOR_SDK_BIN) generate bundle \
--input-dir olm/ \
--package tagger \
--version $(BUNDLE_VERSION) \
--output-dir $(OUTPUT_OLM_BUNDLE)
mv bundle.Dockerfile $(OUTPUT_OLM_BUNDLE)/Containerfile
sed -i 's/output\/bundle\///' $(OUTPUT_OLM_BUNDLE)/Containerfile
sed -i '/scorecard/d' $(OUTPUT_OLM_BUNDLE)/Containerfile

.PHONY: bundle
bundle:
$(IMAGE_BUILDER) build \
-f $(OUTPUT_OLM_BUNDLE)/Containerfile \
--tag=$(BUNDLE_TAG) \
$(OUTPUT_OLM_BUNDLE)

.PHONY: generate-k8s
generate-k8s:
rm -rf $(GEN_OUTPUT) || true
Expand Down
391 changes: 338 additions & 53 deletions NOTES.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ You can deploy Tagger using Helm, let's first select the release we want to inst
the following commands:

```
$ RELEASE=v2.1.16
$ RELEASE=v2.1.17
$ BASEURL=https://github.com/ricardomaraschini/tagger/releases/download
```
The `RELEASE` variable may be set to any release, to see a full list of releases follow the link
Expand Down Expand Up @@ -346,7 +346,7 @@ sudo dnf install -y \
btrfs-progs-devel \
device-mapper-devel
make kubectl-tag
sudo mv _output/bin/kubectl-tag /usr/local/bin/kubectl-tag
sudo mv output/bin/kubectl-tag /usr/local/bin/kubectl-tag
```
You gonna need `go` to be at least version `1.16`. To build in an Ubuntu distribution, after
Expand All @@ -360,5 +360,5 @@ sudo apt install -y \
libdevmapper-dev \
uidmap
make kubectl-tag
sudo mv _output/bin/kubectl-tag /usr/local/bin/kubectl-tag
sudo mv output/bin/kubectl-tag /usr/local/bin/kubectl-tag
```
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon.xcf
Binary file not shown.
33 changes: 33 additions & 0 deletions olm/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tagger
labels:
app: tagger
spec:
replicas: 1
selector:
matchLabels:
app: tagger
template:
metadata:
labels:
app: tagger
spec:
serviceAccountName: tagger
containers:
- name: tagger
image: quay.io/tagger/operator:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
68 changes: 68 additions & 0 deletions olm/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: tagger
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- watch
- get
- list
- update
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- apiGroups:
- ""
resources:
- secrets
verbs:
- watch
- get
- list
- apiGroups:
- ""
resources:
- configmaps
verbs:
- watch
- get
- list
- create
- update
- apiGroups:
- apps
resources:
- replicasets
- deployments
verbs:
- watch
- get
- list
- update
- apiGroups:
- tagger.dev
resources:
- tags
- tags/status
verbs:
- "*"
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
12 changes: 12 additions & 0 deletions olm/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tagger
subjects:
- kind: ServiceAccount
name: tagger
roleRef:
kind: ClusterRole
name: tagger
apiGroup: rbac.authorization.k8s.io
6 changes: 6 additions & 0 deletions olm/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
kind: Secret
metadata:
name: mirror-registry-config
data: {}
6 changes: 6 additions & 0 deletions olm/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
automountServiceAccountToken: true
kind: ServiceAccount
metadata:
name: tagger
72 changes: 72 additions & 0 deletions olm/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
apiVersion: v1
kind: Service
metadata:
name: mutating-webhooks
spec:
selector:
app: tagger
ports:
- protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: quay-webhooks
spec:
selector:
app: tagger
ports:
- protocol: TCP
port: 8081
targetPort: 8081
---
apiVersion: v1
kind: Service
metadata:
name: docker-webhooks
spec:
selector:
app: tagger
ports:
- protocol: TCP
port: 8082
targetPort: 8082
---
apiVersion: v1
kind: Service
metadata:
name: tagio
spec:
selector:
app: tagger
ports:
- protocol: TCP
port: 8083
targetPort: 8083
---
apiVersion: v1
kind: Service
metadata:
name: metrics
spec:
selector:
app: tagger
ports:
- protocol: TCP
port: 8090
targetPort: 8090
---
apiVersion: v1
kind: Service
metadata:
name: tagio-external
spec:
type: LoadBalancer
selector:
app: tagger
ports:
- port: 8083
targetPort: 8083
9 changes: 9 additions & 0 deletions olm/tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
apiVersion: tagger.dev/v1beta1
kind: Tag
metadata:
name: nginx
spec:
from: docker.io/library/nginx:latest
mirror: false
generation: 0
Loading

0 comments on commit 58265cd

Please sign in to comment.