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

Commit

Permalink
fix #129 ensure gcpmanager is included by default (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
samos123 authored Jul 23, 2023
1 parent c617681 commit 4a58efe
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# Image URL to use all building/pushing image targets
IMG ?= docker.io/substratusai/controller-manager:v0.6.4-alpha
VERSION ?= v0.6.5-alpha
IMG ?= docker.io/substratusai/controller-manager:${VERSION}
IMG_GCPMANAGER ?= docker.io/substratusai/gcp-manager:${VERSION}

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.1

Expand Down Expand Up @@ -176,6 +179,7 @@ uninstall-crds: manifests kustomize ## Uninstall CRDs from the K8s cluster speci

install/kubernetes/system.yaml: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/gcpmanager && $(KUSTOMIZE) edit set image gcp-manager=${IMG_GCPMANAGER}
$(KUSTOMIZE) build config/default > install/kubernetes/system.yaml

RUN_SUBSTRATUS_INSTALLER := docker run -it \
Expand Down
1 change: 1 addition & 0 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ resources:
- ../crd
- ../rbac
- ../manager
- ../gcpmanager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
Expand Down
2 changes: 1 addition & 1 deletion config/gcpmanager/gcp-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
- name: gcp-manager
# use this when running via skaffold
# image: us-central1-docker.pkg.dev/substratus-ai-001/substratus/gcpmanager:latest
image: substratusai/gcp-manager:v0.6.3-alpha
image: gcp-manager:latest
imagePullPolicy: Always
ports:
- containerPort: 10080
Expand Down
9 changes: 9 additions & 0 deletions config/gcpmanager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resources:
- gcp-manager.yaml
- bootstrapper-job.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: gcp-manager
newName: docker.io/substratusai/gcp-manager
newTag: v0.6.5-alpha
5 changes: 4 additions & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ kind: Kustomization
images:
- name: controller
newName: docker.io/substratusai/controller-manager
newTag: v0.6.4-alpha
newTag: v0.6.5-alpha
- name: gcp-manager
newName: docker.io/substratusai/gcp-manager
newTag: v0.6.5-alpha
123 changes: 122 additions & 1 deletion install/kubernetes/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,18 @@ metadata:
name: controller-manager
namespace: substratus
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: gcp-manager
namespace: substratus
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: gcp-manager-bootstrapper
namespace: substratus
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand Down Expand Up @@ -1040,6 +1052,21 @@ rules:
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: service-account-annotator
namespace: substratus
rules:
- apiGroups:
- ""
resources:
- serviceaccounts
verbs:
- get
- patch
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
Expand Down Expand Up @@ -1286,6 +1313,20 @@ subjects:
namespace: substratus
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: service-account-annotator-binding
namespace: substratus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: service-account-annotator
subjects:
- kind: ServiceAccount
name: gcp-manager-bootstrapper
namespace: substratus
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
Expand Down Expand Up @@ -1347,6 +1388,19 @@ spec:
selector:
control-plane: controller-manager
---
apiVersion: v1
kind: Service
metadata:
name: gcp-manager
namespace: substratus
spec:
ports:
- port: 10080
protocol: TCP
targetPort: 10080
selector:
app: gcp-manager
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -1421,7 +1475,7 @@ spec:
envFrom:
- configMapRef:
name: system
image: docker.io/substratusai/controller-manager:v0.6.4-alpha
image: docker.io/substratusai/controller-manager:v0.6.5-alpha
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -1451,3 +1505,70 @@ spec:
runAsNonRoot: true
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gcp-manager
namespace: substratus
spec:
replicas: 1
selector:
matchLabels:
app: gcp-manager
template:
metadata:
labels:
app: gcp-manager
spec:
containers:
- image: docker.io/substratusai/gcp-manager:v0.6.5-alpha
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 15
periodSeconds: 20
successThreshold: 1
tcpSocket:
port: 10080
timeoutSeconds: 5
name: gcp-manager
ports:
- containerPort: 10080
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 10m
memory: 64Mi
serviceAccountName: gcp-manager
terminationGracePeriodSeconds: 10
---
apiVersion: batch/v1
kind: Job
metadata:
name: annotate-gcp-manager-sa
namespace: substratus
spec:
backoffLimit: 2
template:
spec:
containers:
- command:
- /bin/bash
- -c
- |
# Get the project ID
PROJECT_ID=$(gcloud config get-value project)
# Get the current region
REGION=$(curl -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/zone | awk -F '/' '{print $4}' | sed 's/-[a-z]$//')
# Set the annotation value
ANNOTATION_VALUE="substratus-gcp-manager@${PROJECT_ID}.iam.gserviceaccount.com"
# Annotate the service account
kubectl annotate serviceaccount -n substratus gcp-manager iam.gke.io/gcp-service-account=${ANNOTATION_VALUE}
image: google/cloud-sdk:latest
name: gcloud
restartPolicy: OnFailure
serviceAccountName: gcp-manager-bootstrapper
ttlSecondsAfterFinished: 120
2 changes: 0 additions & 2 deletions install/scripts/gcp-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,4 @@ if [ "$INSTALL_OPERATOR" == "yes" ]; then
kubectl apply -f kubernetes/namespace.yaml
kubectl apply -f kubernetes/config.yaml
kubectl apply -f kubernetes/system.yaml
kubectl apply -f config/gcpmanager/bootstrapper-job.yaml
kubectl apply -f config/gcpmanager/gcp-manager.yaml
fi

0 comments on commit 4a58efe

Please sign in to comment.