For demo purposes, I find it handy to run openshift with catasb offline, without an internet connection at all.
The cluster will happily start without an internet connection. You can even
provision some services successfully. But due to extensive use of nip.io
,
several things will fail. apb relist
will fail. Using an openshift Route
will fail.
That said, the goal for me was to ensure I can do demos without pulling any images, so it can be done in a low-bandwidth environment. The below does achieve that.
You could exlore running a nip fork locally, which might enable fully-disconnected demos.
Start with a fresh deployment via catasb of OpenShift 3.9. It is a good idea to delete any images from docker.io or quay.io before starting the cluster, so that the only images present in docker later will be the ones required for a 3.9 deployment.
Fire up a local registry.
docker run -d -p 5000:5000 --name registry registry:2
Then after doing a successful start of a cluster with catasb and a normal internet connection, run the following script. It pushes every required image into the local registry.
#!/bin/env bash
for image in $(docker images --format '{{.Repository}}:{{.Tag}}'); do
newname=$(echo $image | sed -e 's/^docker.io/localhost:5000/')
newname=$(echo $newname | sed -e 's/^quay.io/localhost:5000/')
if [[ ${newname::9} == localhost ]]; then
docker tag $image $newname
docker push $newname
fi
done
Create a file called "images.txt". Each line should contain the name of an image on dockerhub. Example:
mhrivnak/postgresql-apb
ansibleplaybookbundle/mediawiki-apb
Run the following script, which will retrieve each image and store it in your local registry:
#!/usr/bin/env bash
file="images.txt"
while IFS= read -r line
do
skopeo copy --dest-tls-verify=false docker://docker.io/$line docker://localhost:5000/$line
done < "$file"
wget https://raw.githubusercontent.com/openshift/ansible-service-broker/release-1.1/templates/deploy-ansible-service-broker.template.yaml
local_oc_client: true
origin_image_tag: v3.9.0
openshift_client_version: '3.9'
broker_tag: v3.9
broker_registry_url: localhost:5000
broker_image_name: localhost:5000/ansibleplaybookbundle/origin-ansible-service-broker
origin_image_name: localhost:5000/openshift/origin
etcd_image_name: localhost:5000/coreos/etcd
awsservicebroker_broker_image_name: localhost:5000/awsservicebroker/aws-service-broker
# Make this path to wherever you saved the template in the step above.
asb_template_url: file:///home/mhrivnak/git/catasb/local/linux/deploy-ansible-service-broker.template.yaml
Disable your internet connection.
Kubernetes requires a default route to start, which is surprising. You can work around that by adding a bogus default route.
sudo ip route add default via 172.17.0.1
Don't forget to remove that route when you're ready to reconnect to the internet!
sudo ip route delete default
Run the script reset_environment.sh
, and it should all work.
Run the following script, which will again read images.txt and copy each image from your local registry into the openshift registry.
#!/usr/bin/env bash
file="images.txt"
while IFS= read -r line
do
name=$(echo $line | sed -e 's/.*\///')
skopeo copy --dest-tls-verify=false --src-tls-verify=false --dest-creds $(oc whoami):$(oc whoami -t) docker://localhost:5000/$line docker://172.30.1.1:5000/openshift/$name
done < "$file"