Skip to content

Commit 6b2a0cf

Browse files
author
Xin Li
authored
Update makefile (#12)
1 parent 25e7b90 commit 6b2a0cf

File tree

8 files changed

+108
-29
lines changed

8 files changed

+108
-29
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build the manager binary
2-
FROM golang:1.13 as builder
2+
FROM golang:1.14.7 as builder
3+
ARG GOARCH
34

45
WORKDIR /workspace
56
# Copy the Go Modules manifests
@@ -15,7 +16,7 @@ COPY api/ api/
1516
COPY controllers/ controllers/
1617

1718
# Build
18-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o namespace-scope-operator-manager main.go
19+
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o namespace-scope-operator-manager main.go
1920

2021
# Use distroless as minimal base image to package the manager binary
2122
# Refer to https://github.com/GoogleContainerTools/distroless for more details

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ deploy: manifests ## Deploy controller in the configured Kubernetes cluster in ~
118118
cd config/manager && $(KUSTOMIZE) edit set image ibm-namespace-scope-operator=$(IMAGE_REPO)/$(OPERATOR_IMAGE_NAME):$(OPERATOR_VERSION)
119119
$(KUSTOMIZE) build config/default | kubectl apply -f -
120120

121+
undeploy: ## Undeploy controller in the configured Kubernetes cluster in ~/.kube/config
122+
cd config/manager && $(KUSTOMIZE) edit set image ibm-namespace-scope-operator=$(IMAGE_REPO)/$(OPERATOR_IMAGE_NAME):$(OPERATOR_VERSION)
123+
$(KUSTOMIZE) build config/default | kubectl delete -f -
124+
121125
##@ Generate code and manifests
122126

123127
manifests: ## Generate manifests e.g. CRD, RBAC etc.
@@ -147,7 +151,7 @@ build-operator-image: ## Build the operator image.
147151
@echo "Building the $(OPERATOR_IMAGE_NAME) docker image for $(LOCAL_ARCH)..."
148152
@docker build -t $(REGISTRY)/$(OPERATOR_IMAGE_NAME)-$(LOCAL_ARCH):$(VERSION) \
149153
--build-arg VCS_REF=$(VCS_REF) --build-arg VCS_URL=$(VCS_URL) \
150-
--build-arg GOARCH=$(LOCAL_ARCH) --build-arg ARCH=$(LOCAL_ARCH) -f Dockerfile .
154+
--build-arg GOARCH=$(LOCAL_ARCH) -f Dockerfile .
151155

152156
##@ Release
153157

config/default/kustomization.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Adds namespace to all resources.
2-
namespace: ibm-namespace-scope-operator-system
2+
namespace: ibm-common-services
33

44
# Value of this field is prepended to the
55
# names of all resources, e.g. a deployment named
66
# "wordpress" becomes "alices-wordpress".
77
# Note that it should also match with the prefix (text before '-') of the namespace
88
# field above.
9-
namePrefix: ibm-namespace-scope-operator-
9+
# namePrefix: ibm-namespace-scope-operator-
1010

1111
# Labels to add to all resources and selectors.
1212
#commonLabels:
@@ -16,6 +16,7 @@ bases:
1616
- ../crd
1717
- ../rbac
1818
- ../manager
19+
- ../samples
1920
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2021
# crd/kustomization.yaml
2122
#- ../webhook
@@ -28,7 +29,7 @@ patchesStrategicMerge:
2829
# Protect the /metrics endpoint by putting it behind auth.
2930
# If you want your controller-manager to expose the /metrics
3031
# endpoint w/o any authn/z, please comment the following line.
31-
- manager_auth_proxy_patch.yaml
32+
# - manager_auth_proxy_patch.yaml
3233

3334
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
3435
# crd/kustomization.yaml

config/manager/manager.yaml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,73 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: ibm-common-services
15
---
26
apiVersion: apps/v1
37
kind: Deployment
48
metadata:
5-
name: controller-manager
6-
namespace: system
9+
name: ibm-namespace-scope-operator
10+
namespace: ibm-common-services
711
labels:
8-
control-plane: controller-manager
12+
app.kubernetes.io/instance: "ibm-namespace-scope-operator"
13+
app.kubernetes.io/managed-by: "ibm-namespace-scope-operator"
14+
app.kubernetes.io/name: "ibm-namespace-scope-operator"
915
spec:
1016
selector:
1117
matchLabels:
12-
control-plane: controller-manager
18+
name: ibm-namespace-scope-operator
1319
replicas: 1
1420
template:
1521
metadata:
1622
labels:
17-
control-plane: controller-manager
23+
name: ibm-namespace-scope-operator
24+
app.kubernetes.io/instance: ibm-namespace-scope-operator
25+
app.kubernetes.io/managed-by: "ibm-namespace-scope-operator"
26+
app.kubernetes.io/name: "ibm-namespace-scope-operator"
27+
annotations:
28+
productName: "IBM Cloud Platform Common Services"
29+
productID: "068a62892a1e4db39641342e592daa25"
30+
productMetric: "FREE"
1831
spec:
1932
serviceAccountName: ibm-namespace-scope-operator
33+
affinity:
34+
nodeAffinity:
35+
requiredDuringSchedulingIgnoredDuringExecution:
36+
nodeSelectorTerms:
37+
- matchExpressions:
38+
- key: beta.kubernetes.io/arch
39+
operator: In
40+
values:
41+
- amd64
42+
- ppc64le
43+
- s390x
2044
containers:
2145
- command:
2246
- /namespace-scope-operator-manager
47+
image: danielxlee/ibm-namespace-scope-operator:1.0.0
48+
imagePullPolicy: Always
49+
name: ibm-namespace-scope-operator
2350
env:
2451
- name: OPERATOR_NAME
25-
value: ibm-namespace-scope-operator
52+
value: "ibm-namespace-scope-operator"
2653
- name: OPERATOR_NAMESPACE
2754
valueFrom:
2855
fieldRef:
2956
apiVersion: v1
3057
fieldPath: metadata.namespace
31-
args:
32-
- --enable-leader-election
33-
image: ibm-namespace-scope-operator:latest
34-
name: manager
3558
resources:
3659
limits:
37-
cpu: 100m
38-
memory: 30Mi
60+
cpu: 500m
61+
memory: 512Mi
3962
requests:
4063
cpu: 100m
41-
memory: 20Mi
64+
memory: 200Mi
65+
securityContext:
66+
allowPrivilegeEscalation: false
67+
capabilities:
68+
drop:
69+
- ALL
70+
privileged: false
71+
readOnlyRootFilesystem: true
72+
runAsNonRoot: true
4273
terminationGracePeriodSeconds: 10

config/rbac/cluster_role.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRole
4+
metadata:
5+
name: ibm-namespace-scope-operator
6+
rules:
7+
- apiGroups:
8+
- operator.ibm.com
9+
resources:
10+
- namespacescopes
11+
verbs:
12+
- create
13+
- delete
14+
- get
15+
- list
16+
- patch
17+
- update
18+
- watch
19+
- apiGroups:
20+
- operator.ibm.com
21+
resources:
22+
- namespacescopes/status
23+
verbs:
24+
- get
25+
- apiGroups:
26+
- ""
27+
resources:
28+
- pods
29+
- configmaps
30+
verbs:
31+
- create
32+
- delete
33+
- get
34+
- list
35+
- patch
36+
- update
37+
- watch

config/rbac/cluster_rolebinding.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
kind: ClusterRoleBinding
4+
metadata:
5+
name: ibm-namespace-scope-operator
6+
roleRef:
7+
apiGroup: rbac.authorization.k8s.io
8+
kind: ClusterRole
9+
name: ibm-namespace-scope-operator
10+
subjects:
11+
- kind: ServiceAccount
12+
name: ibm-namespace-scope-operator

config/rbac/kustomization.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
resources:
22
- role.yaml
33
- role_binding.yaml
4-
- leader_election_role.yaml
5-
- leader_election_role_binding.yaml
6-
# Comment the following 4 lines if you want to disable
7-
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
8-
# which protects your /metrics endpoint.
9-
- auth_proxy_service.yaml
10-
- auth_proxy_role.yaml
11-
- auth_proxy_role_binding.yaml
12-
- auth_proxy_client_clusterrole.yaml
4+
# - cluster_role.yaml
5+
# - cluster_rolebinding.yaml
6+
- service_account.yaml

config/rbac/role.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
---
32
apiVersion: rbac.authorization.k8s.io/v1
43
kind: Role

0 commit comments

Comments
 (0)