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

Commit

Permalink
Merge pull request #66 from crimsonfaith91/one-mc
Browse files Browse the repository at this point in the history
only allow one Metacontroller instance to be active at a time
  • Loading branch information
enisoc authored Jul 23, 2018
2 parents 98b9014 + 8922193 commit 2a992e2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 19 deletions.
4 changes: 2 additions & 2 deletions docs/_guide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Replace `<user>` and `<domain>` above based on the account you use to authentica
```sh
# Create 'metacontroller' namespace, service account, and role/binding.
kubectl apply -f {{ site.repo_raw }}/manifests/metacontroller-rbac.yaml
# Create CRDs for Metacontroller APIs, and the Metacontroller Deployment.
# Create CRDs for Metacontroller APIs, and the Metacontroller StatefulSet.
kubectl apply -f {{ site.repo_raw }}/manifests/metacontroller.yaml
```

Expand All @@ -39,7 +39,7 @@ If you prefer to build and host your own images, please see the
## Configuration

The Metacontroller server has a few settings that can be configured
with command-line flags (by editing the Metacontroller Deployment
with command-line flags (by editing the Metacontroller StatefulSet
in `manifests/metacontroller.yaml`):

| Flag | Description |
Expand Down
8 changes: 5 additions & 3 deletions examples/bluegreen/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ trap cleanup EXIT

set -ex

bgd="bluegreendeployments"

echo "Install controller..."
kubectl create configmap bluegreen-controller -n metacontroller --from-file=sync.js
kubectl apply -f bluegreen-controller.yaml

echo "Wait until CRD is available..."
until kubectl get bgd; do sleep 1; done
until kubectl get $bgd; do sleep 1; done

echo "Create an object..."
kubectl apply -f my-bluegreen.yaml
Expand All @@ -27,14 +29,14 @@ until [[ "$(kubectl get rs nginx-blue -o 'jsonpath={.status.readyReplicas}')" -e
until [[ "$(kubectl get rs nginx-green -o 'jsonpath={.status.replicas}')" -eq 0 ]]; do sleep 1; done

echo "Trigger a rollout..."
kubectl patch bgd nginx --type=merge -p '{"spec":{"template":{"metadata":{"labels":{"new":"label"}}}}}'
kubectl patch $bgd nginx --type=merge -p '{"spec":{"template":{"metadata":{"labels":{"new":"label"}}}}}'

echo "Wait for nginx-green RS to be active..."
until [[ "$(kubectl get rs nginx-green -o 'jsonpath={.status.readyReplicas}')" -eq 3 ]]; do sleep 1; done
until [[ "$(kubectl get rs nginx-blue -o 'jsonpath={.status.replicas}')" -eq 0 ]]; do sleep 1; done

echo "Trigger another rollout..."
kubectl patch bgd nginx --type=merge -p '{"spec":{"template":{"metadata":{"labels":{"new2":"label2"}}}}}'
kubectl patch $bgd nginx --type=merge -p '{"spec":{"template":{"metadata":{"labels":{"new2":"label2"}}}}}'

echo "Wait for nginx-blue RS to be active..."
until [[ "$(kubectl get rs nginx-blue -o 'jsonpath={.status.readyReplicas}')" -eq 3 ]]; do sleep 1; done
Expand Down
14 changes: 8 additions & 6 deletions examples/catset/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@ trap cleanup EXIT

set -ex

cs="catsets"

echo "Install controller..."
kubectl create configmap catset-controller -n metacontroller --from-file=sync.js
kubectl apply -f catset-controller.yaml

echo "Wait until CRD is available..."
until kubectl get catsets; do sleep 1; done
until kubectl get $cs; do sleep 1; done

echo "Create an object..."
kubectl apply -f my-catset.yaml

echo "Wait for 3 Pods to be Ready..."
until [[ "$(kubectl get cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 3 ]]; do sleep 1; done
until [[ "$(kubectl get $cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 3 ]]; do sleep 1; done

echo "Scale up to 4 replicas..."
kubectl patch catset nginx-backend --type=merge -p '{"spec":{"replicas":4}}'
kubectl patch $cs nginx-backend --type=merge -p '{"spec":{"replicas":4}}'

echo "Wait for 4 Pods to be Ready..."
until [[ "$(kubectl get cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 4 ]]; do sleep 1; done
until [[ "$(kubectl get $cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 4 ]]; do sleep 1; done

echo "Scale down to 2 replicas..."
kubectl patch catset nginx-backend --type=merge -p '{"spec":{"replicas":2}}'
kubectl patch $cs nginx-backend --type=merge -p '{"spec":{"replicas":2}}'

echo "Wait for 2 Pods to be Ready..."
until [[ "$(kubectl get cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 2 ]]; do sleep 1; done
until [[ "$(kubectl get $cs nginx-backend -o 'jsonpath={.status.readyReplicas}')" -eq 2 ]]; do sleep 1; done
6 changes: 4 additions & 2 deletions examples/indexedjob/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ trap cleanup EXIT

set -ex

ij="indexedjobs"

echo "Install controller..."
kubectl create configmap indexedjob-controller -n metacontroller --from-file=sync.py
kubectl apply -f indexedjob-controller.yaml

echo "Wait until CRD is available..."
until kubectl get indexedjobs; do sleep 1; done
until kubectl get $ij; do sleep 1; done

echo "Create an object..."
kubectl apply -f my-indexedjob.yaml

echo "Wait for 10 successful completions..."
until [[ "$(kubectl get indexedjob print-index -o 'jsonpath={.status.succeeded}')" -eq 10 ]]; do sleep 1; done
until [[ "$(kubectl get $ij print-index -o 'jsonpath={.status.succeeded}')" -eq 10 ]]; do sleep 1; done

echo "Check that correct index is printed..."
if [[ "$(kubectl logs print-index-9)" != "9" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions manifests/dev/args.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Override args for development mode.
apiVersion: apps/v1beta1
kind: Deployment
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: metacontroller
namespace: metacontroller
Expand Down
4 changes: 2 additions & 2 deletions manifests/dev/image.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Override image for development mode (skaffold fills in the tag).
apiVersion: apps/v1beta1
kind: Deployment
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: metacontroller
namespace: metacontroller
Expand Down
5 changes: 3 additions & 2 deletions manifests/metacontroller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ spec:
singular: controllerrevision
kind: ControllerRevision
---
apiVersion: apps/v1beta1
kind: Deployment
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: metacontroller
namespace: metacontroller
Expand All @@ -55,6 +55,7 @@ spec:
selector:
matchLabels:
app: metacontroller
serviceName: ""
template:
metadata:
labels:
Expand Down

0 comments on commit 2a992e2

Please sign in to comment.