Skip to content

Commit

Permalink
Merge pull request #83 from johnbelamaric/setup-instructions-updates
Browse files Browse the repository at this point in the history
Nephio cluster setup, get repos.sh on the VM
  • Loading branch information
johnbelamaric authored Nov 13, 2022
2 parents 76c409d + d679576 commit 1a2fc5c
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 90 deletions.
34 changes: 33 additions & 1 deletion ansible_kind/scripts/multiclusterkind/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ fi
nephio_gh_filename=${1:-$HOME/nephio-test-github-pat.txt}
base_path=/opt/nephio
system_path="$base_path/system"
webui_path="$base_path/webui"
participant=$(hostname)
participant_path="$base_path/$participant"
KPT_VERSION=1.0.0-beta.23

function _create_gh_secret {
Expand All @@ -38,8 +41,8 @@ function _create_gh_secret {

function _get_pkg {
local pkg="$1"
local url=${2:-"https://github.com/nephio-project/nephio-packages.git/nephio-$pkg"}
local path="$base_path/$pkg"
url="https://github.com/nephio-project/nephio-packages.git/nephio-$pkg"

if ! [ -d "$path" ]; then
sudo -E kpt pkg get --for-deployment "$url" "$path"
Expand All @@ -50,6 +53,17 @@ function _get_pkg {
fi
}

function _install_configsync {
local kubeconfig="$1"
local cluster=$(basename "$kubeconfig" ".config")
local path="$base_path/$cluster"
_get_pkg $cluster https://github.com/nephio-project/nephio-packages.git/nephio-configsync

kpt fn render "$path"
kpt live init "$path" --force --kubeconfig "$kubeconfig"
kpt live apply "$path" --reconcile-timeout=15m --kubeconfig "$kubeconfig"
}

if ! command -v kpt; then
curl -s "https://i.jpillora.com/GoogleContainerTools/kpt@v$KPT_VERSION!" | bash
kpt completion bash | sudo tee /etc/bash_completion.d/kpt >/dev/null
Expand All @@ -64,3 +78,21 @@ _get_pkg system
kpt fn render "$system_path"
kpt live init "$system_path" --force --kubeconfig ~/.kube/nephio.config
kpt live apply "$system_path" --reconcile-timeout=15m --kubeconfig ~/.kube/nephio.config

_get_pkg webui
kpt fn render "$webui_path"
kpt live init "$webui_path" --force --kubeconfig ~/.kube/nephio.config
kpt live apply "$webui_path" --reconcile-timeout=15m --kubeconfig ~/.kube/nephio.config

_get_pkg "$participant" "https://github.com/nephio-project/one-summit-22-workshop.git/packages/participant"
kpt fn render "$participant_path"
kpt live init "$participant_path" --force --kubeconfig ~/.kube/nephio.config
kpt live apply "$participant_path" --reconcile-timeout=15m --kubeconfig ~/.kube/nephio.config

# Install ConfigSync on each workload cluster
for kubeconfig in ~/.kube/*.config; do
if [[ "$kubeconfig" =~ nephio.config$ ]]; then
continue
fi
_install_configsync "$kubeconfig"
done
68 changes: 68 additions & 0 deletions ansible_kind/scripts/multiclusterkind/repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
# SPDX-license-identifier: Apache-2.0
##############################################################################
# Copyright (c) 2022
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

#
# GH_TOKEN is set or ~/nephio-test-github-pat.txt exists.
#
set -o pipefail
set -o errexit
set -o nounset
DEBUG=${DEBUG:-false}
if [[ $DEBUG == "true" ]]; then
set -o xtrace
fi

function usage {
echo "usage: $0 { create | delete } participant ..."
exit 1
}

if [[ $# -lt 2 ]]; then
usage
fi

if ! command -v gh >/dev/null; then
curl -s 'https://i.jpillora.com/cli/cli!?as=gh' | bash
fi

cmd=$1
shift

if [[ $cmd == "create" ]]; then
gh="gh repo create --public "
elif [[ $cmd == "delete" ]]; then
gh="gh repo delete --confirm "
else
usage
fi

if [[ $DEBUG == "true" ]]; then
gh="echo $gh"
fi

token_file="$HOME/nephio-test-github-pat.txt"
export GH_TOKEN=${GH_TOKEN-}

if [[ -z $GH_TOKEN && -f $token_file ]]; then
GH_TOKEN=$(<"$token_file")
fi

if [[ -z $GH_TOKEN ]]; then
echo "GH_TOKEN must be set or $token_file must contain it"
exit 1
fi

repos=(catalog regional edge-1 edge-2)

for p in "$@"; do
for r in "${repos[@]}"; do
$gh "$p-$r"
done
done
63 changes: 42 additions & 21 deletions demo-setup.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,51 @@
# demo setup

Currently here are all the steps needed (that I know of) to fully provision a participant VM. Let's try to make this as automatic as possible. I think we should be able to create an overall script that does most of this - in fact, I know some of these are already tied together in an overall script, but I wanted to list out the main steps I could think of.
VMs are provisioned via Terraform, and within that VM the clusters are setup
using Ansible and other scripts.

@joaofeteira I think this is what you were referring to on the call this morning, that we need this overall script.
GitHub rate limits mean repository creation may fail during bulk VM creation.
If that happens, the VM creation will continue, and we can provision the
repositories separately.

* Login to the [workshop VM](https://console.cloud.google.com/compute/instancesDetail/zones/us-central1-a/instances/workshop?project=pure-faculty-367518&supportedpurview=project)
* `sudo su - workshop`
* `cd one-summit-22-workshop`
* `PARTICPANT=the-participant-username`
* Navigate to the common workshop admin directory, and verify you have the
latest scripts.
```bash
sudo su - workshop
cd one-summit-22-workshop
git pull --ff-only
```
* Adjust the number of VMs to create by editing `infra/compute_instances.tf`,
setting the `num_vms` parameter ([more info](infra/README.md)), then execute terraform:
```bash
cd infra
terraform plan
# you should see that new VMs will be created
terraform apply
```
* The result will give you the name and IP of the new VMs. They are also
available via `gcloud compute instances list`.


## TODO (automation)
* `./scripts/repos.sh create $PARTICIPANT` to create the GitHub repos
* Run the VM creation script to create the participant VM ([see terraform section towards bottom of page](./infra/README.md) )
* Copy the `nephio-test-github-pat.txt` from the workshop VM to the participant VM
* Login to the participant VM
* Run the cluster creation and networking setup scripts
* Create the secret *in each cluster*:
`kubectl create secret generic -ndefault github-personal-access-token --from-literal username=nephio-test --from-file password=~/nephio-test-github-pat.txt --type kubernetes.io/basic-auth`
* Delete the `nephio-test-github-pat.txt` (it's not critical but may as well)
* Install [nephio-system](https://github.com/nephio-project/nephio-poc#installing-the-server-components)
* John needs to update this with latest nephio-controller-poc,
nephio-5gc-controller, and Wim's various IPAM and config injectors
* That will add a bunch of CRDs, etc.
* John also needs to build and push all the images to the registry
* Install [nephio-webui](https://github.com/nephio-project/nephio-poc#installing-the-web-ui)
* Chris is fixing this so we don't need the OAuth stuff anymore, which will be
much simpler.
* Install the [`participant`](https://github.com/nephio-project/one-summit-22-workshop/tree/main/packages/participant)package on the management cluster
* Install [ConfigSync](https://github.com/nephio-project/nephio-poc#installing-config-sync-in-workload-clusters) on the three workload clusters
* Package and instructions probably need updating


## Some commands
* In these commands, `$IP` is the public IP address of the workshop VM.
* To use the UI, you need to forward ports from your workstation to the VM, and
from the VM to the Pod.
```bash
# login from your workstation, forwarding 7007 -> localhost:7007 on the remote VM.
ssh -L7007:localhost:7007 -i ~/.ssh/nephio ubuntu@$IP
# now you are in the remote VM, in there run
kubectl --kubeconfig ~/.kube/nephio.config port-forward --namespace=nephio-webui svc/nephio-webui 7007
```
* On your workstation browse to [http://localhost:7007](http://localhost:7007)
* Create a second, separate login to the workshop VM for CLI access to the
clusters:
```bash
ssh -i ~/.ssh/nephio ubuntu@$IP
```
68 changes: 0 additions & 68 deletions scripts/repos.sh

This file was deleted.

1 change: 1 addition & 0 deletions scripts/repos.sh

0 comments on commit 1a2fc5c

Please sign in to comment.