---
title: "Install Calico on an OpenShift HCP cluster"
description: "Install Calico Open Source on an OpenShift Hosted Control Planes (HCP) cluster, where the control plane is managed and the data plane runs on user-owned nodes."
product: "Calico Open Source"
version: "3.33 (latest)"
section: "Installing and upgrading"
canonical_url: "https://docs.tigera.io/calico/latest/getting-started/kubernetes/openshift/hostedcontrolplanes"
---

# 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)](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/index) clusters on AWS. The steps follow the Red Hat procedure for [deploying hosted control planes on AWS](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/deploying-hosted-control-planes#hcp-deploy-aws), with the changes that Calico needs. Calico is on Red Hat's list of [certified OpenShift CNI plug-ins](https://access.redhat.com/articles/5436171#tigera-6), and the listing covers hosted control planes.

## How to

### Before you begin

- Ensure that your environment meets the Calico [system requirements](https://docs.tigera.io/calico/latest/getting-started/kubernetes/openshift/requirements.md).

- Ensure that you have a [Red Hat account](https://cloud.redhat.com/). 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](https://aws.amazon.com/cli/) and configure it with credentials for your AWS account.

### Create the hosting cluster

Deploy an [OpenShift cluster](https://docs.tigera.io/calico/latest/getting-started/kubernetes/openshift/installation.md) 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:

```text
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](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/preparing-to-deploy-hosted-control-planes#hcp-enable-manual_hcp-enable-disable).

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

   ```text
   oc get managedclusters local-cluster
   ```

3. [Create the S3 bucket and S3 OIDC secret](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/deploying-hosted-control-planes#hcp-aws-create-secret-s3_hcp-deploy-aws).

4. [Create a routable public zone](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/deploying-hosted-control-planes#hcp-aws-create-public-zone_hcp-deploy-aws) for the base domain of your hosted clusters.

5. [Create an AWS IAM role and STS credentials](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/deploying-hosted-control-planes#hcp-aws-create-role-sts-creds_hcp-deploy-aws). 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:

   ```text
   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](https://docs.redhat.com/en/documentation/openshift_container_platform/latest/html/hosted_control_planes/preparing-to-deploy-hosted-control-planes#hcp-cli).

### 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.

```text
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`:

```text
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:

```text
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:

```text
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:

```text
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:

```bash
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.

<!-- tabs -->

**Tab: eBPF (recommended)**

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.

   ```bash
   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.

   ```yaml
   spec:
     template:
       spec:
         (...)
         dnsConfig:
           nameservers:
           - 169.254.169.253 # AWS DNS server
   ```

3. Disable kube-proxy in the OpenShift Cluster Network Operator:

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

**Tab: Iptables**

To install Calico with iptables, you need to:

1. Set `linuxDataplane` to `Iptables` in the `calico/03-cr-installation.yaml` file.

2. Remove the `calico/cluster-network-operator.yaml` and `calico/01-configmap-kubernetes-services-endpoint.yaml` files.

You can do it by running the following command:

```bash
sed -i 's/^\(\s*linuxDataplane:\s*\)BPF/\1Iptables/' calico/03-cr-installation.yaml && \
rm -f calico/cluster-network-operator.yaml && \
rm -f calico/01-configmap-kubernetes-services-endpoint.yaml
```

<!-- /tabs -->

### 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](https://docs.tigera.io/calico/latest/reference/resources.md) 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:
>
> ```text
> 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:

```text
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 has created the CustomResourceDefinitions (CRDs) that the `03*` files need, and the API server has established them. Only then apply the custom resources that install Calico on your cluster:

```text
timeout --foreground 600 bash -c "while ! oc get crd installations.operator.tigera.io apiservers.operator.tigera.io goldmanes.operator.tigera.io whiskers.operator.tigera.io; do sleep 5; done"
oc wait --for=condition=Established --timeout=120s crd/installations.operator.tigera.io crd/apiservers.operator.tigera.io crd/goldmanes.operator.tigera.io crd/whiskers.operator.tigera.io
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.

```text
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](https://docs.tigera.io/calico/latest/networking/configuring/bgp.md) 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](https://docs.tigera.io/calico/latest/networking/determine-best-networking.md).

**Recommended - Security**

- [Secure Calico component communications](https://docs.tigera.io/calico/latest/network-policy/comms/crypto-auth.md)
- [Secure hosts by installing Calico on hosts](https://docs.tigera.io/calico/latest/getting-started/bare-metal/about.md)
- [Secure pods with Calico network policy](https://docs.tigera.io/calico/latest/network-policy/get-started/calico-policy/calico-network-policy.md)
- If you are using Calico with Istio service mesh, get started here: [Enable application layer policy](https://docs.tigera.io/calico/latest/network-policy/istio/app-layer-policy.md)
