Skip to main content
Calico Open Source 3.33 (latest) documentation

Install Calico on an OpenShift HCP cluster

Big picture​

Install Calico on an OpenShift Hosted Control Planes (HCP) cluster.

Value​

Provides steps to install Calico in OpenShift Hosted Control Planes (HCP) clusters on AWS. The steps follow the Red Hat procedure for deploying hosted control planes on AWS, with the changes that Calico needs. Calico is on Red Hat's list of certified OpenShift CNI plug-ins, and the listing covers hosted control planes.

How to​

Before you begin​

  • Ensure that your environment meets the Calico system requirements.

  • Ensure that you have a Red Hat account. You need it to get the pull secret that is required to provision an OpenShift cluster. The OpenShift installer supports a subset of AWS regions.

  • Ensure that you have an AWS account that is configured for OpenShift 4.

  • Install the AWS CLI and configure it with credentials for your AWS account.

Create the hosting cluster​

Deploy an OpenShift cluster with Calico. This will be the hosting cluster with control-plane nodes for all hosted clusters you deploy with the steps below. Set up your KUBECONFIG environment variable to your hosting cluster's kubeconfig file:

export KUBECONFIG=/path/to/kubeconfig

Prepare the hosting cluster for hosted control planes​

Set up the hosted control planes feature on the hosting cluster and create the AWS resources that hosted clusters need. Red Hat documents each of these steps.

  1. Install the multicluster engine for Kubernetes operator, version 2.5 or later, on the hosting cluster. The multicluster engine operator runs the HyperShift operator for you. If the hosted control planes feature is turned off, turn it on.

  2. Verify that the local-cluster managed cluster exists:

    oc get managedclusters local-cluster
  3. Create the S3 bucket and S3 OIDC secret.

  4. Create a routable public zone for the base domain of your hosted clusters.

  5. Create an AWS IAM role and STS credentials. You need the role ARN and the sts-creds.json file when you create the hosted cluster. STS credentials expire, so get new ones if yours have expired.

  6. Install the hcp CLI from the hosting cluster:

    oc get consoleclidownload hcp-cli-download -o jsonpath='{range .spec.links[*]}{.text}{"\t"}{.href}{"\n"}{end}'

    Download the archive for your platform from a link in the output, then extract the hcp binary and add it to your PATH. For more options, see Installing the hosted control planes command-line interface.

Create a hosted cluster​

Create a hosted cluster with no default CNI, so that you can install Calico on it.

  1. Create a HostedCluster and set its HostedCluster.spec.networking.networkType to Other:
note

Make sure to adjust the variables for the command below to the correct values for your cluster, credentials and environment.

HOSTED_CLUSTER_NAME=my-os-hosted-cluster
HOSTED_CLUSTER_NS=clusters
REGION=us-west-2
BASE_DOMAIN=www.example.com
PULL_SECRET="$HOME/.secrets/redhat-pull-secret.txt"
STS_CREDS="$HOME/sts-creds.json"
ROLE_ARN="arn:aws:iam::123456789012:role/hcp-cli-role"

hcp create cluster aws \
--name $HOSTED_CLUSTER_NAME \
--infra-id $HOSTED_CLUSTER_NAME \
--namespace $HOSTED_CLUSTER_NS \
--node-pool-replicas 3 \
--base-domain $BASE_DOMAIN \
--pull-secret $PULL_SECRET \
--sts-creds $STS_CREDS \
--role-arn $ROLE_ARN \
--region $REGION \
--generate-ssh \
--network-type Other

Wait until the hosted cluster reports Available:

oc wait --for=condition=Available --timeout=30m -n $HOSTED_CLUSTER_NS hostedcluster/$HOSTED_CLUSTER_NAME

Then use the hcp CLI to generate the kubeconfig file. Create a separate directory for the hosted cluster, so that you do not mix up configuration and manifests from the hosting and hosted clusters:

mkdir my_hosted_cluster && cd my_hosted_cluster
hcp create kubeconfig --namespace $HOSTED_CLUSTER_NS --name $HOSTED_CLUSTER_NAME > hosted_kubeconfig && export KUBECONFIG=$(pwd)/hosted_kubeconfig

Nodes join the hosted cluster over the next few minutes. They show as NotReady in oc get nodes until you install Calico. This is expected.

Then, copy the aws-creds secret from the hosting cluster to the hosted cluster. Run this using the hosting cluster kubeconfig to extract the secret to a yaml file:

oc get secrets --kubeconfig /path/to/hosting/kubeconfig -n kube-system aws-creds -o yaml > aws-creds.yaml

Then import it in the hosted cluster:

oc apply --kubeconfig /path/to/hosted/kubeconfig -f aws-creds.yaml
note

There is no need to specify the --kubeconfig CLI argument if the hosted cluster's kubeconfig file is configured as the KUBECONFIG environment variable in your shell.

Download the Calico install manifests​

Download the Calico manifests for OpenShift:

mkdir calico
wget -qO- https://github.com/projectcalico/calico/releases/download/v3.33.0/ocp.tgz | \
tar xvz --strip-components=1 -C calico

Select and configure a data plane​

Calico manifests for OpenShift are ready to configure and install the eBPF data plane. The steps in the eBPF (recommended) tab below will guide you through the process. You can also select a different tab to follow the steps for configuring another data plane.

To configure the eBPF data plane, you need to:

  1. Set the KUBERNETES_SERVICE_HOST attribute in the calico/01-configmap-kubernetes-services-endpoint.yaml file. You can use the oc config view command to look at the server attribute for the cluster. The following extracts the URL from the oc config view command and sets it.

    API_SERVER_URL=$(oc config view | sed -n 's/.*server: https:\/\/\([^:]*\).*/\1/p') && \
    sed -i "s|^\([^:]*KUBERNETES_SERVICE_HOST: \).*\$|\1\"$API_SERVER_URL\"|" calico/01-configmap-kubernetes-services-endpoint.yaml
  2. Include the following spec.template.spec.dnsConfig.nameservers block to resolve the apiserver DNS in the calico/02-tigera-operator.yaml file. For clusters in AWS, the DNS server address is 169.254.169.253.

    spec:
    template:
    spec:
    (...)
    dnsConfig:
    nameservers:
    - 169.254.169.253 # AWS DNS server
  3. Disable kube-proxy in the OpenShift Cluster Network Operator:

    oc patch network.operator.openshift.io cluster --type merge --patch '{"spec":{"deployKubeProxy":false}}'

Optionally provide additional configuration​

You may want to provide Calico with additional configuration at install-time. For example, BGP configuration or peers. You can use a Kubernetes ConfigMap with your desired Calico resources to set configuration as part of the installation. If you do not need to provide additional configuration, you can skip this section.

To include Calico resources during installation, edit calico/02-configmap-calico-resources.yaml to add your own configuration.

note

If you have a directory with the Calico resources, you can create the file with the command:

oc create configmap -n tigera-operator calico-resources \
--from-file=<resource-directory> --dry-run -o yaml \
calico/02-configmap-calico-resources.yaml

With recent versions of oc it is necessary to have a kubeconfig configured or add --server='127.0.0.1:443' even though it is not used.

note

If you have provided a calico-resources configmap and the tigera-operator pod fails to come up with Init:CrashLoopBackOff, check the output of the init-container with oc logs -n tigera-operator -l k8s-app=tigera-operator -c create-initial-resources.

Apply the Calico install manifests​

Apply the install manifests paying attention to the required order. First apply all necessary manifests to install the Tigera Operator:

cd calico/
ls 00* | xargs -n1 oc apply -f
ls 01* | xargs -n1 oc apply -f
ls 02* | xargs -n1 oc apply -f

Then wait until the Tigera Operator creates the necessary CustomResourceDefinitions (CRDs) before applying the CustomResources to install Calico on your cluster:

timeout --foreground 600 bash -c "while ! kubectl get crd installations.operator.tigera.io; do sleep 5; done" # wait until CRDs are created by the operator
ls 03* | xargs -n1 oc apply -f
note

You can safely ignore any ls: cannot access '0X*': No such file or directory errors if there's no yaml files with that prefix to be applied.

Once the above commands are complete, you can verify Calico is installed by verifying the components are available with the following command.

oc get tigerastatus
note

To get more information, add -o yaml to the above command.

Next steps​

Recommended - Networking

  • If you are using the default BGP networking with full-mesh node-to-node peering with no encapsulation, go to Configure BGP peering to get traffic flowing between pods.
  • If you are unsure about networking options, or want to implement encapsulation (overlay networking), see Determine best networking option.

Recommended - Security