Ocean is a managed infrastructure service for Kubernetes that automatically adjusts infrastructure capacity and size to meet the needs of all pods, containers, and applications.

This tutorial covers the creation of an Ocean cluster using Spot.

Prerequisites
  • OpenShift is installed and configured on AWS or GCP.
  • At least one worker node is up and running, with a primed image and user-data. To set up the primed image and user data, you may follow the procedures below.
Create Primed Image

To create the primed image, complete the Red Hat procedure.

Create User Data

To create user data, follow the Red Hat steps below. (These steps are taken from a Red Hat procedure.)

1. Create the bootstrap.kubeconfig file by generating it from a master node.

$ ssh master "sudo oc serviceaccounts create-kubeconfig -n openshift-infra node-bootstrapper" > ~/bootstrap.kubeconfig

2. Create the user-data.txt cloud-init file from the bootstrap.kubeconfig file.

$ cat <<EOF > user-data.txt
#cloud-config
write_files:
- path: /root/openshift_bootstrap/openshift_settings.yaml
  owner: 'root:root'
  permissions: '0640'
  content: |
    openshift_node_config_name: node-config-compute
- path: /etc/origin/node/bootstrap.kubeconfig
  owner: 'root:root'
  permissions: '0640'
  encoding: b64
  content: |
    $(base64 ~/bootstrap.kubeconfig | sed '2,$s/^/    /')

runcmd:
- [ ansible-playbook, /root/openshift_bootstrap/bootstrap.yml]
- [ systemctl, restart, systemd-hostnamed]
- [ systemctl, restart, NetworkManager]
- [ systemctl, enable, atomic-openshift-node]
- [ systemctl, start, atomic-openshift-node]
EOF
Note: If you don’t use an autoscaler in the OpenShift cluster yet and don’t have an AWS auto-scaling group, do not create an autoscaling group.

3. Launch an instance based on the created prime image together with the user data built on the cluster and ensure all your OpenShift AWS resources are tagged with the following tag: 

Key:kubernetes.io/cluster/<cluster-name> Value:<shared/owned>

The tag values are:

shared  – The resource is shared with other systems.

owned – The node belongs exclusively to the cluster.

Once the instance is up and running, a new csr request will be waiting:

oc get csr

This request will output all the pending CSRs.

Use the following request to approve the one that is relevant to the instance you’ve launched.

oc approve csr csrname

When the new instance with the correct user data, image, and tags is joined to the cluster, you are ready integrate OpenShift with Ocean.

Step 1: Create Ocean Cluster
  • In the side menu of the console, click Ocean/Cloud Clusters.

  • Click Create Cluster.
  • Click  the use case for OpenShift, “Join an Existing OpenShift Cluster”.

Step 2: Enter General Information
  • Enter a Cluster Name and Identifier and choose a Region.
  • Choose an Auto Scaling Group or worker node Instance to import the cluster configuration from.

Step 3: Review Compute Settings
  • Confirm or change the settings imported by the Ocean Creation Wizard.

Step 4: Set up Connectivity
  • Create a Spotinst token or use an existing one.
  • Install the Spotinst Controller Pod. Learn more about the Spotinst Controller Pod and Ocean’s anatomy here.
  • Ensure enable-csr-approval is set to True.
  • Click Test Connectivity to ensure the controller functionality.
#!/usr/bin/env bash
curl -fsSL http://spotinst-public.s3.amazonaws.com/integrations/kubernetes/cluster-controller/scripts/init.sh | \
SPOTINST_TOKEN=<ENTER YOUR TOKEN HERE> \
SPOTINST_ACCOUNT=act-54c5d1ab \
SPOTINST_CLUSTER_IDENTIFIER=open-shift \
ENABLE-CSR-APPROVAL=True \
bash

  • When the connectivity test is complete, click Create.

You’re all set! Ocean will now ensure the most cost-effective capacity and size possible for your cluster.

What’s Next?

Learn more about Ocean scaling and optimization features here.