How To: Add a new AWS EKS cluster to Codefresh programmatically

This article describes how to add a new cluster created in a pipeline to Codefresh programmatically.

How to

  1. Create a variable for the cluster name, such as $K8S_NAME.
  2. After the cluster is created, run the following API call, replacing all placeholders with your values or variables:

add_new_cluster:
    image: <your-image>
    commands:
        - curl -s --fail \
            -H "Authorization: <CF_API_KEY>" \
            -H "content-type: application/json;charset=UTF-8" \
            -d \
            "{
                \"type\": \"sat\",
                \"selector\": \"<K8S_NAME>\",
                \"host\": \"<K8S_HOST>\",
                \"clientCa\": \"<K8S_CA>\",
                \"serviceAccountToken\": \<$K8S_TOKEN\>,
                \"provider\": \"local\",
                \"providerAgent\": \"eks\"
            }" \
            "$CF_API_HOST/api/clusters/local/cluster"

See the detailed EKS workflow.

API documentation - clusters