This post describes how to get set up with a Portal v1 testing environment.
Setup OpenShift Code Ready Containers
Start here
this requires a RedHat login, but not any sort of subscription. Download the Code Ready Containers Archive for your OS along with the pull secret.
Extract the CRC archive
tar xf crc-linux-amd64.tar.xz
cd crc-linux-1.20.0-amd64
Configure CRC to have enough resources to run a Merge Portal. Here we have 32 cores and 64G of memory and 200G of disk, you can probably get away with about half of this.
./crc config set cpus 32
./crc config set memory 65536
./crc config set disk-size 200
Stash the pull secret you downloaded somehere and tell CRC where to find it
crc config set pull-secret-file <path-to-pull-secret>
Setup and start CRC
./crc setup
./crc start
eval $(./crc oc-env)
Display the CRC credentials for later use
./crc console --credentials
First login to the ‘developer’ account and grab the token.
oc login -u developer -p developer
DEVTOKEN=$(oc whoami -t)
Now login to the admin credentials displayed previously
oc login -u kubeadmin -p <token> https://api.crc.testing:6443
Save the OKD registry host in a variable for later use
HOST=$(oc get route default-route -n openshift-image-registry --template='{{ .spec.host }}')
Build the Portal
The installer can be made in a self-contained, self-extracting way, but that’s not the goal here. We want to use the logic of the installer to get things started, but feed it the artifacts we build to deploy instead of ones it grabs from CI.
First clone the portal code
git clone git@gitlab.com:mergetb/portal/services
cd services
git checkout ry-v1
Install the ymk
build tool
curl -OL https://gitlab.com/mergetb/devops/ymk/-/jobs/940984772/artifacts/raw/ymk
chmod +x ymk
sudo cp ymk /usr/local/bin
Build the portal code
export DOCKER=podman REGISTRY=$HOST REGISTRY_PATH=merge TAG=latest
ymk tools.yml
ymk build.yml
ymk containers.yml
Build and Configure the Installer
First clone the installer code
git clone git@gitlab.com:mergetb/portal/install
Make sure you have the tools needed
sudo dnf install -y makeself device-mapper-devel btrfs-progs-devel gpgme-devel
Build
go build
Make a directory called build
and copy the installer there
mkdir build
cp installer build/
Go to the build directory and create a merge
directory and put the containers you built in the portal build step there.
cd build
mkdir -p containers/{merge,xdc}
cp <path-to-portal-code>/build/*.tar containers/merge/
If you are using a recent build of the portal with compressed containers then you’ll need to uncompress the xz archives in place
cd containers/merge
for x in `ls`; do unxz $x; done
cd ../..
Move xdc containers to the expected location
mv containers/merge/{ssh-jump,xdc-base,wgd}.tar containers/xdc/
Copy the example installer config to the build directory
cp ../example/portal.yml .
Edit portal.yml
, specifically
- change
kubeconfig
to the location of your CRC kubernetes config. This should be~/.crc/machines/crc/kubeconfig
on *nix type machines. - change
openshift.registry.password
to the content of theDEVTOKEN
environment variable created earlier. Note that this token expires over time, so if you use it at a later time, you may need to refresh the value fromoc whoami -t
.
Run the preflight.sh
script in the top level installer directory.
../preflight.sh
your install/build
directory should now look like this
[install/build]$ tree
.
├── containers
│ ├── merge
│ │ ├── apiserver.tar
│ │ ├── cred.tar
│ │ ├── git-server.tar
│ │ ├── identity.tar
│ │ ├── materialize.tar
│ │ ├── mergefs.tar
│ │ ├── model.tar
│ │ ├── ops-init.tar
│ │ ├── pops.tar
│ │ ├── realize.tar
│ │ ├── step-ca.tar
│ │ ├── wgsvc.tar
│ │ └── xdc.tar
│ ├── merge-auth
│ │ ├── kratos.tar
│ │ ├── postgres.tar
│ │ └── user-ui.tar
│ └── xdc
│ ├── ssh-jump.tar
│ ├── wgd.tar
│ └── xdc-base.tar
├── installer
└── portal.yml
Wait until the openshift-controller-manger
has started
oc get pods -n openshift-controller-manager
NAME READY STATUS RESTARTS AGE
controller-manager-vbsw9 0/1 ContainerCreating 0 36s
some time passes …
oc get pods -n openshift-controller-manager
NAME READY STATUS RESTARTS AGE
controller-manager-vbsw9 1/1 Running 0 89s
Now we can run the Merge portal installer against OpenShift.
./installer --config portal.yml
Once this installer finishes you’ll have a working Merge portal running inside your OpenShift cluster. A good sanity check is the following.
oc get pods -n merge
NAME READY STATUS RESTARTS AGE
apiserver-5c97dc85f5-jn9kj 1/1 Running 0 116s
etcd-95d54bdb5-t6jns 1/1 Running 0 117s
git-server-56554c5795-tjfdx 1/1 Running 0 115s
identity-77d4bb67b-vjgrx 1/1 Running 0 116s
minio-6d66649fc7-dxp8k 1/1 Running 0 117s
model-fc8b5fcd5-66fzd 1/1 Running 0 115s
ops-init-cnt7v 0/1 Error 0 114s
ops-init-pfmg7 0/1 Completed 0 40s
realize-556bbf7d9b-c6r4r 1/1 Running 0 115s
Seeing a few errors on the ops-init
job is normal, as it starts at the same time the pods it depends no, but eventually succeeds once sufficient infrastructure is up.
Doing work
I would highly recommend using the OpenShift web console.
./crc console
will open a browser window. Select Log in with … kube:admin, and provide the login credentials from
./crc console --credentials
Add the following to your /etc/hosts
192.168.130.11 api.mergetb.example.net auth.mergetb.example.net grpc.mergetb.example.net git.mergetb.example.net
Getting started with the v1 client
First check out and build the code
git clone git@gitlab.com:mergetb/portal/cli
cd cli
git checkout ry-v1
go build -o mrg
Now login with the credentials generated by the installer. Change directory back to installer/build
cat .conf/generated.yml | grep opspw
opspw: BlOouW27DS08IgY65qE1saf4Pm3Jyi9j
mrg login --nokeys ops BlOouW27DS08IgY65qE1saf4Pm3Jyi9j
Now a quick sanity check to make sure the portal is initialized
mrg config set server grpc.mergetb.example.net
mrg list id
USERNAME EMAIL ADMIN
ops ops@mergetb.example.net true
you are now ready to take over the world.
Pushing Updated Containers to the Portal
If you need to re-build and and push containers to the portal, you do not need to run the installer again. Go back to the services
repo and
oc login -u developer -p developer
podman login -u $(oc whoami) -p $(oc whoami -t) --tls-verify=false $HOST
export DOCKER=podman DOCKER_PUSH_ARGS=--tls-verify=false
ymk push-containers.yml
Alternatively to push individual containers you can just use podman
on it’s own, for example
podman push --tls-verify=false default-route-openshift-image-registry.apps-crc.testing/merge/apiserver