Skip to content

Commit df10b9f

Browse files
committed
Initial controller
1 parent dc56b51 commit df10b9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1141
-203
lines changed

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
# Binaries for programs and plugins
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
bin
9+
10+
# Test binary, build with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Kubernetes Generated files - skip generated files, except for vendored files
17+
18+
!vendor/**/zz_generated.*
19+
20+
# editor and IDE paraphernalia
21+
.idea
22+
*.swp
23+
*.swo
24+
*~

Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build the manager binary
2+
FROM golang:1.12.5 as builder
3+
4+
WORKDIR /workspace
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
12+
# Copy the go source
13+
COPY main.go main.go
14+
COPY api/ api/
15+
COPY controllers/ controllers/
16+
17+
# Build
18+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
19+
20+
# Use distroless as minimal base image to package the manager binary
21+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22+
FROM gcr.io/distroless/static:nonroot
23+
WORKDIR /
24+
COPY --from=builder /workspace/manager .
25+
USER nonroot:nonroot
26+
27+
ENTRYPOINT ["/manager"]

Makefile

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
12
# Image URL to use all building/pushing image targets
2-
IMG ?= adcs-issuer:latest
3+
IMG ?= controller:latest
34
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
45
CRD_OPTIONS ?= "crd:trivialVersions=true"
56

@@ -14,23 +15,23 @@ all: manager
1415

1516
# Run tests
1617
test: generate fmt vet manifests
17-
go test ./api/... ./controllers/... -coverprofile cover.out
18+
go test ./... -coverprofile cover.out
1819

1920
# Build manager binary
2021
manager: generate fmt vet
2122
go build -o bin/manager main.go
2223

2324
# Run against the configured Kubernetes cluster in ~/.kube/config
24-
run: generate fmt vet
25+
run: generate fmt vet manifests
2526
go run ./main.go
2627

2728
# Install CRDs into a cluster
2829
install: manifests
29-
kubectl apply -f config/crd/bases
30+
kustomize build config/crd | kubectl apply -f -
3031

3132
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
3233
deploy: manifests
33-
kubectl apply -f config/crd/bases
34+
cd config/manager && kustomize edit set image controller=${IMG}
3435
kustomize build config/default | kubectl apply -f -
3536

3637
# Generate manifests e.g. CRD, RBAC etc.
@@ -47,13 +48,11 @@ vet:
4748

4849
# Generate code
4950
generate: controller-gen
50-
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...
51+
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..."
5152

5253
# Build the docker image
5354
docker-build: test
5455
docker build . -t ${IMG}
55-
@echo "updating kustomize image patch file for manager resource"
56-
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml
5756

5857
# Push the docker image
5958
docker-push:
@@ -63,10 +62,8 @@ docker-push:
6362
# download controller-gen if necessary
6463
controller-gen:
6564
ifeq (, $(shell which controller-gen))
66-
go get sigs.k8s.io/controller-tools/cmd/controller-gen
67-
#go get sigs.k8s.io/controller-tools/cmd/[email protected]
65+
go get sigs.k8s.io/controller-tools/cmd/[email protected]
6866
CONTROLLER_GEN=$(GOBIN)/controller-gen
6967
else
7068
CONTROLLER_GEN=$(shell which controller-gen)
7169
endif
72-

PROJECT

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
domain: certmanager.csf.nokia.com
3+
repo: github.com/chojnack/adcs-issuer
4+
resources:
5+
- group: adcs
6+
version: v1
7+
kind: AdcsRequest

README.md

-1
This file was deleted.

adcs-issuer

-1.81 MB
Binary file not shown.

api/v1/adcsrequest_types.go

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
package v1
17+
18+
import (
19+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20+
)
21+
22+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
23+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
24+
25+
// AdcsRequestSpec defines the desired state of AdcsRequest
26+
type AdcsRequestSpec struct {
27+
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
28+
// Important: Run "make" to regenerate code after modifying this file
29+
}
30+
31+
// AdcsRequestStatus defines the observed state of AdcsRequest
32+
type AdcsRequestStatus struct {
33+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
34+
// Important: Run "make" to regenerate code after modifying this file
35+
}
36+
37+
// +kubebuilder:object:root=true
38+
39+
// AdcsRequest is the Schema for the adcsrequests API
40+
type AdcsRequest struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec AdcsRequestSpec `json:"spec,omitempty"`
45+
Status AdcsRequestStatus `json:"status,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
50+
// AdcsRequestList contains a list of AdcsRequest
51+
type AdcsRequestList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []AdcsRequest `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&AdcsRequest{}, &AdcsRequestList{})
59+
}

api/v1/groupversion_info.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
*/
15+
16+
// Package v1 contains API Schema definitions for the adcs v1 API group
17+
// +kubebuilder:object:generate=true
18+
// +groupName=adcs.certmanager.csf.nokia.com
19+
package v1
20+
21+
import (
22+
"k8s.io/apimachinery/pkg/runtime/schema"
23+
"sigs.k8s.io/controller-runtime/pkg/scheme"
24+
)
25+
26+
var (
27+
// GroupVersion is group version used to register these objects
28+
GroupVersion = schema.GroupVersion{Group: "adcs.certmanager.csf.nokia.com", Version: "v1"}
29+
30+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
31+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
32+
33+
// AddToScheme adds the types in this group-version to the given scheme.
34+
AddToScheme = SchemeBuilder.AddToScheme
35+
)

api/v1/zz_generated.deepcopy.go

+113
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)