separate adduser and createproject
This commit is contained in:
@@ -38,7 +38,7 @@ if [ $? -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Templating namespace with helm and copying to server"
|
echo "Templating namespace with helm and copying to server"
|
||||||
helm template $USER ./namespace | ssh $SERVER "cat - > $SERVER_USER_DIR/namespace.yaml"
|
helm template $USER --set user=$USER ./namespace | ssh $SERVER "cat - > $SERVER_USER_DIR/namespace.yaml"
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to template namespace. Is helm installed?"
|
echo "Failed to template namespace. Is helm installed?"
|
||||||
45
createprojectspace.sh
Executable file
45
createprojectspace.sh
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PROJECT=$1
|
||||||
|
export USER=$2
|
||||||
|
export SERVER=$3
|
||||||
|
|
||||||
|
export SERVER_PROJECT_DIR="~/.kube/projects/$PROJECT"
|
||||||
|
|
||||||
|
echo "Checking if project namespace exists"
|
||||||
|
exists=$(ssh $SERVER "kubectl get namespace --output=jsonpath=\"{.items[?(@.metadata.name=='$PROJECT')].metadata.name}\"")
|
||||||
|
if [ -z $exists ]; then
|
||||||
|
echo "Namespace not found, creating"
|
||||||
|
else
|
||||||
|
echo "Namespace exists, not overwriting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating namespace dir on server"
|
||||||
|
ssh $SERVER "mkdir -p $SERVER_PROJECT_DIR"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to create server project dir"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Templating namespace with helm and copying to server"
|
||||||
|
helm template $PROJECT ./namespace --set user=$USER | ssh $SERVER "cat - > $SERVER_PROJECT_DIR/namespace.yaml"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to template namespace. Is helm installed?"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Creating namespace from template"
|
||||||
|
ssh $SERVER "kubectl apply -f $SERVER_PROJECT_DIR/namespace.yaml"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Failed to create namespace"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "adding server to config with new context $SERVER-$USER"
|
||||||
|
kubectl config set-context $SERVER-$USER-$PROJECT --cluster=$SERVER --namespace=$PROJECT --user=$USER-$SERVER
|
||||||
|
kubectl config set current-context $SERVER-$USER-$PROJECT
|
||||||
|
echo "done"
|
||||||
@@ -5,7 +5,7 @@ metadata:
|
|||||||
namespace: {{ .Release.Name }}
|
namespace: {{ .Release.Name }}
|
||||||
subjects:
|
subjects:
|
||||||
- kind: User
|
- kind: User
|
||||||
name: {{ .Release.Name }}
|
name: {{ .Values.user }}
|
||||||
apiGroup: ""
|
apiGroup: ""
|
||||||
roleRef:
|
roleRef:
|
||||||
kind: Role
|
kind: Role
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
user: admin
|
||||||
Reference in New Issue
Block a user