Enhance deployment scripts and add gitignore
* move ssh key creation to a folder * add knownhost file to /dev/null * add cleanup script * add gitignore Signed-off-by: Sreejith Punnapuzha <Sreejith.Punnapuzha@outlook.com> Change-Id: Ie34c7db34ecdbea9d06709eebeffc398c0a662c8
This commit is contained in:
parent
745e834a1e
commit
50a9c75933
|
@ -0,0 +1,28 @@
|
||||||
|
# Binaries for programs and plugins
|
||||||
|
*.exe
|
||||||
|
*.exe~
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
bin/
|
||||||
|
|
||||||
|
# Test binary, build with `go test -c`
|
||||||
|
*.test
|
||||||
|
*.example
|
||||||
|
|
||||||
|
# Output of the go coverage tool
|
||||||
|
*.out
|
||||||
|
.coverage/
|
||||||
|
|
||||||
|
# Various user specific files
|
||||||
|
.DS_Store
|
||||||
|
.idea/
|
||||||
|
.vimrc
|
||||||
|
*.swp
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Sphinx build venv
|
||||||
|
.tox/
|
||||||
|
|
||||||
|
# Generated SSH key folder
|
||||||
|
ssh/
|
|
@ -25,6 +25,7 @@ sudo apt-get install -y openssl sshpass jq
|
||||||
ENCRYPTED_PASSWORD=`openssl passwd -crypt $PASSWORD`
|
ENCRYPTED_PASSWORD=`openssl passwd -crypt $PASSWORD`
|
||||||
|
|
||||||
# Configuring SSH on Kubernetes nodes
|
# Configuring SSH on Kubernetes nodes
|
||||||
|
mkdir -p ssh
|
||||||
for i in "${!hosts[@]}"
|
for i in "${!hosts[@]}"
|
||||||
do
|
do
|
||||||
sudo docker exec ${hosts[i]} apt-get update
|
sudo docker exec ${hosts[i]} apt-get update
|
||||||
|
@ -33,8 +34,8 @@ do
|
||||||
sudo docker exec ${hosts[i]} useradd -m -p $ENCRYPTED_PASSWORD -s /bin/bash $USERNAME
|
sudo docker exec ${hosts[i]} useradd -m -p $ENCRYPTED_PASSWORD -s /bin/bash $USERNAME
|
||||||
sudo docker exec ${hosts[i]} bash -c "echo '$USERNAME ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/hostconfig"
|
sudo docker exec ${hosts[i]} bash -c "echo '$USERNAME ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/hostconfig"
|
||||||
printf 'Working on host %s with Indexs and having IP %s\n' "${hosts[i]}" "$i" "${hosts_ips[i]}"
|
printf 'Working on host %s with Indexs and having IP %s\n' "${hosts[i]}" "$i" "${hosts_ips[i]}"
|
||||||
ssh-keygen -q -t rsa -N '' -f ${hosts[i]}
|
ssh-keygen -q -t rsa -N '' -f ssh/${hosts[i]}
|
||||||
sshpass -p $PASSWORD ssh-copy-id -o StrictHostKeyChecking=no -i ${hosts[i]} $USERNAME@${hosts_ips[i]}
|
sshpass -p $PASSWORD ssh-copy-id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ssh/${hosts[i]} $USERNAME@${hosts_ips[i]}
|
||||||
kubectl create secret generic ${hosts[i]} --from-literal=username=$USERNAME --from-file=ssh_private_key=${hosts[i]}
|
kubectl create secret generic ${hosts[i]} --from-literal=username=$USERNAME --from-file=ssh_private_key=ssh/${hosts[i]}
|
||||||
kubectl annotate node ${hosts[i]} secret=${hosts[i]}
|
kubectl annotate node ${hosts[i]} secret=${hosts[i]}
|
||||||
done
|
done
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
kind delete cluster --name hostconfig
|
||||||
|
sudo docker rmi -f $(sudo docker images --all -q | xargs -I{} sudo bash -c 'if docker image inspect {} | grep -q kind; then echo {} ; fi')
|
||||||
|
rm -rf ssh
|
Loading…
Reference in New Issue