forked from MoserMichael/s9k
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Moser
committed
Jul 30, 2020
1 parent
7394517
commit 7cb5a62
Showing
6 changed files
with
235 additions
and
59 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,41 @@ | ||
# Build... | ||
FROM golang:1.14.4-alpine3.11 AS build | ||
|
||
RUN mkdir -p src/github.com/MoserMichael/s9k | ||
WORKDIR ./src/github.com/MoserMichael/s9k | ||
|
||
COPY go.mod go.sum exec.go s9k.sh s9k.py Makefile ./ | ||
ADD ./static-file ./static-file | ||
|
||
|
||
COPY vendor vendor | ||
RUN apk --no-cache add make curl && pwd && ls -al && make kubexec-no-mod && ls -al | ||
# ----------------------------------------------------------------------------- | ||
# Build Image... | ||
|
||
FROM alpine:3.10.0 | ||
|
||
COPY --from=build /go/src/github.com/MoserMichael/s9k/kubeexec /bin/kubeexec | ||
COPY --from=build /go/src/github.com/MoserMichael/s9k/s9k.py /bin/s9k.py | ||
COPY --from=build /go/src/github.com/MoserMichael/s9k/s9k.sh /bin/s9k.sh | ||
COPY --from=build /go/src/github.com/MoserMichael/s9k/static-file /static-file | ||
|
||
|
||
ENV KUBE_LATEST_VERSION="v1.18.1" | ||
|
||
#RUN apk update \ | ||
# && apk add --update ca-certificates \ | ||
# && apk add --update -t deps binutils file gcc libc-dev libev python3-dev libffi-dev curl python3 py3-pip \ | ||
# && (pip3 install -v bottle bottle-websocket || /bin/true) | ||
|
||
RUN apk update \ | ||
&& apk add --update ca-certificates \ | ||
&& apk add --update -t deps binutils file gcc make libc-dev libev python3-dev libffi-dev curl python3 py3-pip openssl \ | ||
&& pip3 install -v bottle bottle-websocket \ | ||
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -o /bin/kubectl \ | ||
&& chmod +x /bin/kubectl \ | ||
&& rm /var/cache/apk/* | ||
|
||
# && apk del --purge deps py3-pip curl make gcc binutils \ | ||
|
||
ENTRYPOINT [ "/bin/s9k.sh", "-d", "-v" ] |
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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/sh | ||
|
||
PORT="8000" | ||
HOST=127.0.0.1 | ||
KUBE_DIR="$HOME/.kube" | ||
IMAGE_LOCATION="quay.io/mmoser/s9k-mm" | ||
|
||
Help() { | ||
cat <<EOF | ||
Start s9k in docker | ||
$0 -r [-p <port>] [-i <host>] [-d <dir>] [-v] [-c <image>] | ||
Stop s9k in docker | ||
Run s9k web server in a docker; by default the docker image is fetched from a public repository. ($IMAGE_LOCATION) | ||
The web server creates a self-signed certificate on each docker run | ||
Start the web server fir s9k | ||
-r - start the web server | ||
-p <port> - listening port (default ${PORT}) | ||
-i <host> - listening host (default ${HOST}) | ||
-d <dir> - directory where kube config is (default ${KUBE_DIR}) | ||
Stop the web server for s9k | ||
-s - stop the web server | ||
Common options: | ||
-c <image> - override the container image location (default ${IMAGE_LOCATION}) | ||
-v - run verbosely | ||
EOF | ||
|
||
exit 1 | ||
} | ||
|
||
while getopts "hrsvi:p:c:" opt; do | ||
case ${opt} in | ||
h) | ||
Help | ||
;; | ||
r) | ||
ACTION="start" | ||
;; | ||
s) | ||
ACTION="stop" | ||
;; | ||
p) | ||
PORT="$OPTARG" | ||
;; | ||
i) | ||
HOST="$OPTARG" | ||
;; | ||
c) | ||
IMAGE_LOCATION="$OPTARG" | ||
;; | ||
d) | ||
KUBE_DIR="$OPTARG" | ||
;; | ||
v) | ||
set -x | ||
export PS4='+(${BASH_SOURCE}:${LINENO}) ' | ||
;; | ||
*) | ||
Help "Invalid option" | ||
;; | ||
esac | ||
done | ||
|
||
if [[ $ACTION == 'start' ]]; then | ||
docker run --network=host -v $KUBE_DIR:/kube-mount -e DHOST=$HOST -e DPORT=$PORT -dt ${IMAGE_LOCATION} | ||
echo "Listen on https://${HOST}:${PORT}" | ||
else | ||
if [[ $ACTION == 'stop' ]]; then | ||
DOCKER_ID=$(docker ps | grep ${IMAGE_LOCATION}[[:space:]] | awk '{ print $1 }') | ||
docker stop $DOCKER_ID | ||
docker rm $DOCKER_ID | ||
else | ||
Help 'must use either to start the server -r or to stop it -s' | ||
fi | ||
fi | ||
|
Oops, something went wrong.