Skip to content

Commit

Permalink
feat: Add AWS EKS ARN support for remote cluster name (#7161)
Browse files Browse the repository at this point in the history
* feat: Add AWS EKS ARN support for remote cluster name

- Extend validation to allow AWS EKS ARN format for REMOTE_CLUSTER_NAME
- Extract cluster name from ARN if REMOTE_CLUSTER_NAME is in ARN format
- Update error messages to reflect new validation rules

* fix: Add AWS EKS ARN support for remote cluster name

* fix: regex for AWS eks

* Refactor: AWS EKS ARN regex pattern in kiali-prepare-remote-cluster.sh

* Refactor: Remove unnecessary echo statement in create_kiali_remote_cluster_secret() function
  • Loading branch information
isarns committed Mar 3, 2024
1 parent 757c6b4 commit fb71761
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hack/istio/multicluster/kiali-prepare-remote-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ create_kiali_remote_cluster_secret() {
local cert_auth_yaml="certificate-authority-data: ${remote_cluster_ca_bytes}"
fi

# Check if the REMOTE_CLUSTER_NAME matches the AWS EKS ARN regex pattern.
# If it does, extract the cluster name from the ARN and assign it back to REMOTE_CLUSTER_NAME.
AWS_REGION_REGEX='(us|eu|ap|sa|ca|me|af|il|us-gov)-(north|south|east|west|central|southeast|northeast)-[0-9]'
AWS_EKS_ARN_REGEX="arn:aws:eks:${AWS_REGION_REGEX}:[0-9]{12}:cluster/([0-9A-Za-z][_A-Za-z0-9\-]{0,99})$"
if echo "${REMOTE_CLUSTER_NAME}" | grep -Eq "${AWS_EKS_ARN_REGEX}"; then
REMOTE_CLUSTER_NAME=$(echo "${REMOTE_CLUSTER_NAME}" | sed 's/^.*:cluster\/\(.*\)$/\1/')
fi
# a Secret stringData key must conform to Kubernetes naming rules. Othewise, this kind of error will result:
# a valid config key must consist of alphanumeric characters, '-', '_' or '.'
# (e.g. 'key.name', or 'KEY_NAME', or 'key-name', regex used for validation is '[-._a-zA-Z0-9]+')
Expand Down

0 comments on commit fb71761

Please sign in to comment.