Revert "changes"

This reverts commit 20445794d6.
This commit is contained in:
2018-09-30 14:11:52 -04:00
parent 20445794d6
commit 64309ce7d1
4 changed files with 56 additions and 102 deletions
+32 -15
View File
@@ -28,7 +28,7 @@ from .kubectl import kubectl
@logme.log
class Operator:
def __init__(self, api_client=None, fetch_buildpacks=True):
def __init__(self, api_client=None):
# Ensure that we can load the kubeconfig.
self.ensure_kubeconfig()
@@ -44,7 +44,8 @@ class Operator:
self.ensure_registry()
# Fetch all the buildpacks.
c = self.fetch_buildpacks()
c = self.spawn_fetch_buildpacks()
c.block()
@property
def installed_buildpacks(self):
@@ -152,19 +153,35 @@ class Operator:
self.logger.info("Ensuring Registry service...")
kubectl(f"apply -f ./deploy/registry-service.yml -n {WATCH_NAMESPACE}")
def watch(self, fork=True, buildpacks=False, apps=False):
if buildpacks and apps:
raise RuntimeError("Can only watch one at a time: buildpacks and apps.")
def watch(self):
self.logger.info("Pretending to watch...")
time.sleep(5)
if fork:
subprocesses = []
for t in ("apps", "buildpacks"):
cmd = f"bruce-operator watch --{t}"
self.logger.info(f"Running $ {cmd} in the background.")
c = delegator.run(cmd, block=False)
subprocesses.append(c)
operator = Operator()
self.logger.info(f"Blocking on subprocesses completion.")
for subprocess in subprocesses:
subprocess.block()
@logme.log
def watch(fork=True, buildpacks=False, apps=False, logger=None):
if buildpacks and apps:
raise RuntimeError("Can only watch one at a time: buildpacks and apps.")
if fork:
subprocesses = []
cmd = f"bruce-operator fetch-buildpacks"
logger.info(f"Running $ {cmd} in the background.")
c = delegator.run(cmd, block=False)
subprocesses.append(c)
for t in ("apps", "buildpacks"):
logger.info(f"Fetching buildpacks in the background.")
cmd = f"bruce-operator watch --{t}"
logger.info(f"Running $ {cmd} in the background.")
c = delegator.run(cmd, block=False)
subprocesses.append(c)
logger.info(f"Blocking on subprocesses completion.")
for subprocess in subprocesses:
subprocess.block()
+1
View File
@@ -10,3 +10,4 @@ OPERATOR_IMAGE = "kennethreitz/bruce-operator:latest"
TOKEN_LOCATION = "/var/run/secrets/kubernetes.io/serviceaccount/token"
CERT_LOCATION = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
IN_KUBERNETES = os.path.isfile(TOKEN_LOCATION)
KUBECONFIG_PATH = os.path.expanduser("~/.kube/config")
+21 -85
View File
@@ -1,11 +1,3 @@
---
kind: Namespace
apiVersion: v1
metadata:
name: bruce
labels:
name: bruce
---
apiVersion: v1
kind: ServiceAccount
metadata:
@@ -41,19 +33,6 @@ subjects:
name: bruce-operator
namespace: bruce
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
name: buildpacks-volume
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
status: {}
---
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -67,15 +46,13 @@ spec:
metadata:
labels:
name: bruce-operator
namespace: bruce
spec:
serviceAccountName: bruce-operator
containers:
- name: bruce-operator
image: kennethreitz/bruce-operator:latest
imagePullPolicy: Always
volumeMounts:
- mountPath: /opt/buildpacks
name: buildpacks-volume
env:
- name: WATCH_NAMESPACE
valueFrom:
@@ -85,10 +62,17 @@ spec:
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: C:\Users\me\OneDrive\system\bin\kompose.exe convert -f .\kubernetes-compose.yml
kompose.version: 1.1.0 (36652f6)
creationTimestamp: null
labels:
io.kompose.service: bruce-operator
name: bruce-operator
spec:
clusterIP: None
selector:
io.kompose.service: bruce-operator
status:
loadBalancer: {}
---
@@ -107,6 +91,19 @@ spec:
scope: Namespaced
version: v1alpha1
---
metadata:
creationTimestamp: null
labels:
io.kompose.service: buildpacks-volume
name: buildpacks-volume
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
status: {}
---
apiVersion: v1
items:
- apiVersion: bruce.kennethreitz.org/v1alpha1
@@ -187,64 +184,3 @@ spec:
singular: app
scope: Namespaced
version: v1alpha1
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
creationTimestamp: null
name: bruce-registry-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
status: {}
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: C:\Users\me\OneDrive\system\bin\kompose.exe convert -f .\kubernetes-compose.yml
kompose.version: 1.1.0 (36652f6)
creationTimestamp: null
name: registry
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
creationTimestamp: null
spec:
containers:
- env:
- name: REGISTRY_HTTP_ADDR
value: 0.0.0.0:80
image: registry:2
name: registry
resources: {}
volumeMounts:
- mountPath: /var/lib/registry
name: bruce-registry-data
restartPolicy: Always
volumes:
- name: bruce-registry-data
persistentVolumeClaim:
claimName: bruce-registry-data
status: {}
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
name: registry
spec:
clusterIP: None
ports:
- name: registry-http
port: 80
# nodePort: 80
targetPort: 0
status:
loadBalancer: {}
+2 -2
View File
@@ -1,4 +1,4 @@
docker build --tag kennethreitz/bruce-operator .
docker push kennethreitz/bruce-operator
kubectl delete -f .\deploy\operator.yml
kubectl create -f .\deploy\operator.yml --validate=false -n bruce
kubectl delete -f .\deploy\operator.yml -n bruce
kubectl create -f .\deploy\operator.yml -n bruce