Skip to content
Snippets Groups Projects
Verified Commit 9c554157 authored by Varac's avatar Varac
Browse files

Remove obsolete control parts

parent c37c1feb
No related branches found
No related tags found
No related merge requests found
......@@ -23,23 +23,6 @@ ci_test_image:
- test/Dockerfile
- test/requirements.txt
control_image:
stage: build
variables:
DOCKER_DRIVER: overlay2
image: docker:stable
services:
- docker:dind
before_script:
- docker info
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -t ${CI_REGISTRY_IMAGE}/oas-control control/
- docker push ${CI_REGISTRY_IMAGE}/oas-control
only:
changes:
- control/**/*
bootstrap:
stage: deploy
image: "${CI_REGISTRY_IMAGE}/bootstrap-ci"
......
# https://hub.docker.com/r/chatwork/helmfile/tags
# Version strings contains: helmfile version - helm version - ??
FROM chatwork/helmfile:0.43.2-2.12.3-1.11.7
LABEL name="Openappstack control image"
LABEL version="0.3"
LABEL maintainer="arie@greenhost.nl,varac@varac.net"
RUN apk --no-cache add openssh-client bash-completion
COPY files/bin/rke /usr/local/bin/
COPY files/bin/control /usr/local/bin/
COPY files/k8s-config/ /control/k8s-config
COPY files/bashrc /root/.bashrc
COPY files/kubectl.completion /etc/bash_completion.d/
ENV KUBECONFIG="/control/local/kube/config"
ENTRYPOINT []
This folder contains the files necessary to make the `control` docker container.
This container can be used to manage your Kubernetes cluster from a container
*within kubernetes*.
#!/bin/bash
export PS1="\[\e[1;31m\]control shell \$\[\e[0m\] "
# Enable bash_completion
. /usr/share/bash-completion/bash_completion
echo 'This is the "control" docker image for managing your oas cluster.'
echo 'The following programs are available to view and administer the cluster:'
echo ' kubectl'
echo ' helm'
echo ' helmfile'
echo ' rke'
echo 'These are the currently installed helm releases:'
echo '======== `helm ls`'
helm ls
echo '========'
#!/bin/bash
command=$1
read -r ip < "/oas/config/ip"
buildCluster()
{
echo "Setting up OpenAppStack cluster."
mkdir -p "/control/config"
clusterConfigFile="/control/local/rke/cluster.yml"
rke up --config="$clusterConfigFile" &>> /oas/logs/rke.log || exit
mkdir -p "/control/local/kube"
# Copy kubectl config file generated by rke.
cp "/control/local/rke/kube_config_cluster.yml" "/control/local/kube/config"
}
installTiller()
{
kubectl apply -f "/control/k8s-config/tiller-permissions.yml"
helm init --service-account=tiller
# Wait for tiller to become available.
kubectl rollout status -n kube-system deployment/tiller-deploy
}
createStorage()
{
pushd "/control/k8s-config/storage" || return
shopt -s nullglob
for yaml in ./*.yaml ./*.yml
do
kubectl apply -f "$yaml"
storageDir=$(grep '/var/local/k8s/[^"]*' -o "$yaml")
ssh -i "/oas/config/ssh_key" "root@${ip}" "mkdir -p \"$storageDir\" && chmod a+w \"$storageDir\""
done
}
getRepos()
{
reposDir="/oas/source/repos"
mkdir -p "$reposDir"
for repo in "helmfiles" "charts"
do
target="${reposDir}/${repo}"
if ! [ -d "$target" ]
then
echo "Getting ${repo}."
git clone "https://code.greenhost.net/openappstack/${repo}" "$target" || exit
else
echo "Already have ${repo}, updating."
pushd "$target"
git pull
popd
fi
done
}
configureKeycloak()
{
kubectl create secret generic realm-secret "--from-file=/control/k8s-config/realm.json" --dry-run -o yaml | kubectl apply -f -
}
configFiles()
{
mkdir -p "/oas/config/values/apps"
for app in traefik keycloak
do
# Create corresponding file to set extra overriding values.
touch "/oas/config/values/apps/${app}.yaml"
done
}
applyHelmfiles()
{
helmfile -e oas -f "/oas/source/repos/helmfiles/helmfile.d" apply
}
case "$command" in
setup)
buildCluster
installTiller
createStorage
getRepos
configureKeycloak
configFiles
applyHelmfiles
;;
*)
$command
esac
File deleted
{
"realm": "OpenAppStack",
"enabled": true,
"sslRequired": "external",
"registrationAllowed": true,
"requiredCredentials": [ "password" ],
"roles" : {
"realm" : [
{
"name": "user",
"description": "User privileges"
},
{
"name": "admin",
"description": "Administrator privileges"
}
]
}
}
kind: PersistentVolume
apiVersion: v1
metadata:
name: keycloak-postgres
labels:
type: local
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
hostPath:
path: "/var/local/k8s/keycloak-postgres"
type: DirectoryOrCreate
kind: PersistentVolume
apiVersion: v1
metadata:
name: traefik-pv-acme
labels:
type: local
spec:
capacity:
storage: 10Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/var/local/k8s/traefik-pv-acme"
type: DirectoryOrCreate
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: tiller-clusterrolebinding
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: ""
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment