-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from phudtran/local-docker-dev
Adjusted docker push/pull workflow for local dev
- Loading branch information
Showing
11 changed files
with
151 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
KINDCONF=${1:-"${HOME}/mizar/build/tests/kind/config"} | ||
USER=${2:-dev} | ||
|
||
# create registry container unless it already exists | ||
reg_name='local-kind-registry' | ||
reg_port='5000' | ||
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" | ||
if [ "${running}" != 'true' ]; then | ||
docker run \ | ||
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \ | ||
registry:2 | ||
fi | ||
reg_ip="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' "${reg_name}")" | ||
|
||
if [[ $USER == "dev" ]]; then | ||
PATCH="containerdConfigPatches: | ||
- |- | ||
[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"localhost:${reg_port}\"] | ||
endpoint = [\"http://${reg_ip}:${reg_port}\"]" | ||
REPO="localhost:5000" | ||
else | ||
PATCH="" | ||
REPO="fwnetworking" | ||
fi | ||
|
||
# create a cluster with the local registry enabled in containerd | ||
cat <<EOF | kind create cluster --name kind --kubeconfig ${KINDCONF} --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
${PATCH} | ||
nodes: | ||
- role: control-plane | ||
image: ${REPO}/kindnode:latest | ||
extraMounts: | ||
- hostPath: . | ||
containerPath: /var/mizar | ||
- role: worker | ||
image: ${REPO}/kindnode:latest | ||
extraMounts: | ||
- hostPath: . | ||
containerPath: /var/mizar | ||
- role: worker | ||
image: ${REPO}/kindnode:latest | ||
extraMounts: | ||
- hostPath: . | ||
containerPath: /var/mizar | ||
- role: worker | ||
image: ${REPO}/kindnode:latest | ||
extraMounts: | ||
- hostPath: . | ||
containerPath: /var/mizar | ||
- role: worker | ||
image: ${REPO}/kindnode:latest | ||
extraMounts: | ||
- hostPath: . | ||
containerPath: /var/mizar | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
#!/bin/bash | ||
|
||
DIR=${1:-.} | ||
USER=${2:-user} | ||
DOCKER_ACC=${3:-fwnetworking} | ||
USER=${2:-dev} | ||
DOCKER_ACC=${3:-"localhost:5000"} | ||
YAML_FILE="dev.daemon.deploy.yaml" | ||
|
||
if [[ "$USER" == "user" || "$USER" == "final" ]]; then | ||
DOCKER_ACC="fwnetworking" | ||
YAML_FILE="daemon.deploy.yaml" | ||
fi | ||
|
||
# Build the daemon image | ||
docker image build -t $DOCKER_ACC/dropletd:latest -f $DIR/mgmt/etc/docker/daemon.Dockerfile $DIR | ||
if [[ "$USER" == "dev" ]]; then | ||
if [[ "$USER" == "dev" || "$USER" == "final" ]]; then | ||
docker image push $DOCKER_ACC/dropletd:latest | ||
fi | ||
|
||
# Delete existing deployment and deploy | ||
kubectl delete daemonset.apps/mizar-daemon | ||
kubectl apply -f $DIR/mgmt/etc/deploy/daemon.deploy.yaml | ||
kubectl delete daemonset.apps/mizar-daemon 2> /tmp/kubetctl.err | ||
kubectl apply -f $DIR/mgmt/etc/deploy/$YAML_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
#!/bin/bash | ||
|
||
DIR=${1:-.} | ||
USER=${2:-user} | ||
DOCKER_ACC=${3:-fwnetworking} | ||
USER=${2:-dev} | ||
DOCKER_ACC=${3:-"localhost:5000"} | ||
YAML_FILE="dev.operator.deploy.yaml" | ||
|
||
if [[ "$USER" == "user" || "$USER" == "final" ]]; then | ||
DOCKER_ACC="fwnetworking" | ||
YAML_FILE="operator.deploy.yaml" | ||
fi | ||
|
||
# Build the operator image | ||
docker image build -t $DOCKER_ACC/endpointopr:latest -f $DIR/mgmt/etc/docker/operator.Dockerfile $DIR | ||
if [[ "$USER" == "dev" ]]; then | ||
if [[ "$USER" == "dev" || "$USER" == "final" ]]; then | ||
docker image push $DOCKER_ACC/endpointopr:latest | ||
fi | ||
|
||
# Delete existing deployment and deploy | ||
kubectl delete deployment.apps/mizar-operator | ||
kubectl apply -f $DIR/mgmt/etc/deploy/operator.deploy.yaml | ||
kubectl delete deployment.apps/mizar-operator 2> /tmp/kubetctl.err | ||
kubectl apply -f $DIR/mgmt/etc/deploy/$YAML_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
DIR=${1:-.} | ||
USER=${2:-user} | ||
USER=${2:-dev} | ||
|
||
kubectl delete daemonsets -n kube-system kube-proxy |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: mizar-daemon | ||
namespace: default | ||
spec: | ||
selector: | ||
matchLabels: | ||
job: mizar-daemon | ||
template: | ||
metadata: | ||
labels: | ||
job: mizar-daemon | ||
spec: | ||
serviceAccountName: mizar-operator | ||
hostNetwork: true | ||
hostPID: true | ||
volumes: | ||
- name: mizar | ||
hostPath: | ||
path: /home | ||
type: Directory | ||
containers: | ||
- image: localhost:5000/dropletd:latest | ||
name: mizar-daemon | ||
securityContext: | ||
privileged: true | ||
volumeMounts: | ||
- name: mizar | ||
mountPath: /mizar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mizar-operator | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: mizar-operator | ||
template: | ||
metadata: | ||
labels: | ||
app: mizar-operator | ||
mizar: operator | ||
spec: | ||
serviceAccountName: mizar-operator | ||
hostNetwork: true | ||
containers: | ||
- image: localhost:5000/endpointopr:latest | ||
name: mizar-operator | ||
securityContext: | ||
privileged: true |