Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Service installation for Kubernetes - #11338

Merged
szkl merged 10 commits into
koding:masterfrom
mertaytore:master
Aug 22, 2017
Merged

szkl merged 10 commits into
koding:masterfrom
mertaytore:master

Conversation

@mertaytore

@mertaytore mertaytore commented Jun 30, 2017 •

Copy link
Copy Markdown
Contributor

Initial version of the installation process for Kubernetes.

Description

I added two new commands to the auto-generated ./run script: ./run k8s start and ./run k8s stop. Start runs to check whether the dependencies have been previously installed or not. If they have, workers pod is created according to the pod definition in containers.yaml.template
Stop command stops the running Kubernetes cluster (minikube)

Motivation and Context

A step for Koding on K8s. After having a copy of this repository, ./configure is needed to be executed to have a ./run script. If the dependencies regarding Kubernetes are fulfilled, ./run k8s start builds up a local Kubernetes cluster. As a result, Koding runs on team stack for development :8090

How Has This Been Tested?

Services' connectivities are tested via their respective check_connectivity functions.

Types of changes

  • New feature (non-breaking change which adds functionality)

@mertaytore
mertaytore requested review from cihangir and szkl June 30, 2017 13:11
@CLAassistant

CLAassistant commented Jun 30, 2017 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@szkl szkl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's best to create a new file which sets related environment variables for a service. k8s command would source that file. It is possible to have connectivity checks that way.

Comment thread config/generateRunFile.coffee Outdated
if [ "$param" == "start" ]; then
command -v VirtualBox >/dev/null 2>&1 || { echo >&2 "I require curl but it's not installed. Aborting."; exit 1; }
command -v minikube >/dev/null 2>&1 || { echo >&2 "I require a Kubernetes cluster. To install minikube: \
(curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.20.0/minikube-darwin-amd64 && chmod +x minikube && mv minikube /usr/local/bin/)"; exit 1;}

@cihangir cihangir Jun 30, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the naming scheme is consistent in download links, you could infer the the os and replace linux/darwin with that in URLs

Comment thread config/generateRunFile.coffee Outdated
minikube start

if [[ `uname` == 'Darwin' ]]; then
command -v helm >/dev/null 2>&1 || { echo >&2 "I require kubernetes-helm but it's not installed. (brew install kubernetes-helm maybe?)"; exit 1; }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mertaytore
mertaytore force-pushed the master branch 2 times, most recently from 7dbffee to 7a74309 Compare July 3, 2017 18:18
@mertaytore

Copy link
Copy Markdown
Contributor Author

ready for another review, updated the PR description.

@mertaytore
mertaytore force-pushed the master branch 6 times, most recently from 77099d7 to a799a46 Compare July 25, 2017 14:56
Comment thread config/generateRunFile.coffee Outdated
export MINIKUBE_IP=$(minikube ip)
eval $(minikube docker-env)

docker image inspect baseinstall:v1 >/dev/null 2>&1 && echo yes || echo no >/tmp/response.log 2>&1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you dont need to write to a file to get the response, you could have it in the exported value

➜  cat test.sh
#!/bin/bash

function fail() { return 1; }
function succ() { return 0; }

succ && echo "succeeded"
fail || echo "failed"

# set the default behaviour
export RESULT="no";

succ && RESULT="yes"
echo $RESULT

fail || RESULT="no"
echo $RESULT

➜ ./test.sh
succeeded
failed
yes
no

Comment thread config/generateRunFile.coffee Outdated

if [[ "$IMAGE_RESPONSE" == "no" ]]; then
echo 'base installation docker image for koding was not found, building the image:\n'
docker build -t baseinstall:v1 -f Dockerfile-k8s-base .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets not build the image in user machines, that might create security issues where we can add sensitive information that the codebase has.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Base images should be generally available already and also must not contain any installation-specific files.

Comment thread config/generateRunFile.coffee Outdated
docker build -t baseinstall:v1 -f Dockerfile-k8s-base .
fi

minikube ssh "docker pull mongo:3.2.8"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these operations should not be required, kubernetes handles the image pull ops

Comment thread config/generateRunFile.coffee Outdated

kubectl create -f $KONFIG_PROJECTROOT/deployment/kubernetes/backend/backend-deployment.yaml

export BACKEND_POD_NAME=$(kubectl get pods --namespace default -l "app=backend" -o jsonpath="{.items[0].metadata.name}")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • better to use a specific namespace instead of the default one
  • app=backend is not a good selector where many other test apps can have "backend" in the default namespace - not an issue once we switch to a dev namespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made changes to all reviews accordingly; created a namespace named service-dev (replacing default namespace) and renamed app label to service-installations.

@mertaytore
mertaytore force-pushed the master branch 9 times, most recently from aa5ea88 to 6bf6c85 Compare August 3, 2017 15:00
@mertaytore
mertaytore force-pushed the master branch 6 times, most recently from afc9c4f to 418d290 Compare August 15, 2017 19:27
@mertaytore
mertaytore force-pushed the master branch 4 times, most recently from 565f0b7 to 91ee97a Compare August 21, 2017 13:27
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@mertaytore
mertaytore force-pushed the master branch 2 times, most recently from 6b10f13 to 184721c Compare August 21, 2017 15:22
@szkl
szkl merged commit a68fb62 into koding:master Aug 22, 2017
@cihangir

Copy link
Copy Markdown
Contributor

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants