Skip to content

Commit

Permalink
Merge pull request #6 from rguske/issue-3
Browse files Browse the repository at this point in the history
Feature: Add option to join an existing k8s appliance node
  • Loading branch information
rguske committed Mar 14, 2022
2 parents afffeca + f18158a commit 69a170c
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,6 @@ I'm a happy user of [zsh](https://www.zsh.org/) and [oh-my-zsh](https://github.c

## Change Log

- [2022-03-14] Added option to join an existing K8s Appliance Node (v0.3.0)
- [2022-03-10] Added `local-path-provisioner` (v0.2.1)
- [2022-03-10] Updated to VMware PhotonOS v4 Rev.2 (v0.2.0)
16 changes: 16 additions & 0 deletions files/setup-04-kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,20 @@ kubectl apply -f local-path-storage.yaml
# Set default K8s Storageclass
kubectl patch sc local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'

# Join as a new Node

if [ -n "${NODE_FQDN}" ]; then
echo -e "\e[92mJoining an existing Control Plane Node ..." > /dev/console

# Create token on Master Node
NODE_TOKEN=$(sshpass -p ${NODE_PASSWORD} ssh -o 'StrictHostKeyChecking no' root@${NODE_FQDN} kubeadm token create)
DISCOVERY_TOKEN=$(sshpass -p ${NODE_PASSWORD} ssh -o 'StrictHostKeyChecking no' root@${NODE_FQDN} openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //')

# Reset kubeadm config on the node
kubeadm reset --force

# Join Node
kubeadm join ${NODE_FQDN}:6443 --token ${NODE_TOKEN} --discovery-token-ca-cert-hash sha256:${DISCOVERY_TOKEN} --ignore-preflight-errors=All
fi

# End of Script
1 change: 1 addition & 0 deletions files/setup-05-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sed -i '83i plugins=(git zsh-syntax-highlighting)' ~/.zshrc
# ZSH Autocompletion for kubectl
sed -i -e '$aif [ /usr/bin/kubectl ]; then source <(kubectl completion zsh); fi' ~/.zshrc

echo -e "\e[92mInstalling Helm ..." > /dev/console
# Install Helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
Expand Down
2 changes: 2 additions & 0 deletions files/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ GATEWAY=$(/root/setup/getOvfProperty.py "guestinfo.gateway")
DNS_SERVER=$(/root/setup/getOvfProperty.py "guestinfo.dns")
DNS_DOMAIN=$(/root/setup/getOvfProperty.py "guestinfo.domain")
NTP_SERVER=$(/root/setup/getOvfProperty.py "guestinfo.ntp")
NODE_FQDN=$(/root/setup/getOvfProperty.py "guestinfo.node_fqdn")
NODE_PASSWORD=$(/root/setup/getOvfProperty.py "guestinfo.node_password")
HTTP_PROXY=$(/root/setup/getOvfProperty.py "guestinfo.http_proxy")
HTTPS_PROXY=$(/root/setup/getOvfProperty.py "guestinfo.https_proxy")
PROXY_USERNAME=$(/root/setup/getOvfProperty.py "guestinfo.proxy_username")
Expand Down
2 changes: 1 addition & 1 deletion k8s-app-bom.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"appliance": {
"version": "v0.2.1"
"version": "v0.3.0"
},
"antrea": {
"gitRepoTag": "v1.2.0",
Expand Down
9 changes: 9 additions & 0 deletions manual/photon.xml.template
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
<Label>NTP</Label>
<Description>NTP Servers (space separated)</Description>
</Property>
<Category>Join as a new Worker Node</Category>
<Property ovf:key="guestinfo.node_fqdn" ovf:type="string" ovf:userConfigurable="true">
<Label>FQDN or IP Control Plane Node</Label>
<Description>Enter the FQDN or IP of the existing Control Plane Node. Example: "k8s-app-1.jarvis.tanzu"</Description>
</Property>
<Property ovf:key="guestinfo.node_password" ovf:password="true" ovf:type="string" ovf:userConfigurable="true" ovf:value="">
<Label>Root Password (Control Plane Node)</Label>
<Description>Root Password of the existing Control Plane Node</Description>
</Property>
<Category>Proxy Settings (optional)</Category>
<Property ovf:key="guestinfo.http_proxy" ovf:type="string" ovf:userConfigurable="true">
<Label>HTTP Proxy</Label>
Expand Down
3 changes: 2 additions & 1 deletion scripts/photon-settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ tdnf install -y \
unzip \
awk \
tar \
jq
jq \
sshpass

echo '> Adding K8s Repo'
curl -L https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg -o /etc/pki/rpm-gpg/GOOGLE-RPM-GPG-KEY
Expand Down

0 comments on commit 69a170c

Please sign in to comment.