Code Monkey home page Code Monkey logo

argocd-k8s-auth-gke-wli-eks's Introduction

ArgoCD external cluster EKS config provider for GKE (workload identity)

The purpose of this application is to facilitate identity based (without use of any permanents credentials) authentication of EKS clusters in ArgoCD running on Google Kubernetes Engine (GKE) clusters with workload identity.

Table of Contents

Introduction

A scenario this application covers is an ArgoCD instance running on GKE and using workload identity and Google Cloud -> AWS IAM role federation to authenticate EKS clusters without need of providing any kind of long term credentials. The program uses GKE/GCE provided OAuth token to assume AWS role and generate pre-signed URL for EKS authentication.

Prerequisites

  1. A Google Cloud environment configured with IAM identity. This could be a VM instance using a service account identity or a GKE pod configured with GKE workload identity. In the case of ArgoCD this means having argocd-server and argocd-application-controller deployments using workload identity. Workload identity can be easily configured using the official workload identity terraform module.
  2. An AWS role that is configured to trust the GCP service account used in the environment running the program. In the case of ArgoCD these are the service accounts used by the argocd-server and argocd-application-controller deployments/pods. This involves setting up AWS IAM role trust policy for sts:AssumeRoleWithWebIdentity action specifying accounts.google.com federated principal (more documentation here).
  3. The IAM role from step 3. having appropriate permissions (policies attached) for EKS cluster(s) management.

Getting started

Installation

Download precompiled binary for your platform from the repository' releases page. In the case of ArgoCD the binary has to be available in the argocd-server and argocd-application-controller deployments/pods.

The binary can be shipped via custom ArgoCD images, or added via volume mounts and placed in the argocd-server and argocd-application-controller deployments/pods.

Example for ArgoCD official Helm Chart:

controller and server:
  ...
  initContainers:
   - name: download-tools
     image: alpine:3
     command: [sh, -c]
     args:
       - wget -qO k8s-auth-gke-wli-eks https://github.com/zepellin/argocd-k8s-auth-gke-wli-eks/releases/download/v0.1.0/k8s-auth-gke-wli-eks-v0.1.0-linux-amd64 && chmod +x k8s-auth-gke-wli-eks && mv k8s-auth-gke-wli-eks /argo-k8s-auth-gke-wli-eks/
     volumeMounts:
       - mountPath: /argo-k8s-auth-gke-wli-eks
         name: argo-k8s-auth-gke-wli-eks

  volumeMounts:
   - mountPath: /usr/local/bin/k8s-auth-gke-wli-eks
     name: argo-k8s-auth-gke-wli-eks
     subPath: k8s-auth-gke-wli-eks

  volumes:
   - name: argo-k8s-auth-gke-wli-eks
     emptyDir: {}

Usage

The program takes following arguments:

  • -rolearn: The AWS IAM role ARN to assume (required).
  • -cluster: The name of the AWS EKS cluster for which you need credentials (required).
  • -stsregion: AWS STS region to which requests are made (optional, default: us-east-1).

Example:

$ k8s-auth-gke-wli-eks -rolearn "arn:aws:iam::123456789012:role/argocdrole" -cluster "my-eks-cluster-name" -stsregion "us-east-1"

ArgoCD Configuration

Create a secret defining secret in your ArgoCD namespace where data.config is base64 encoded section as in following example.

apiVersion: v1
kind: Secret
metadata:
  name: my-eks-cluster-name-secret
  labels:
    argocd.argoproj.io/secret-type: cluster
type: Opaque
stringData:
  name: my-eks-cluster-name
  server: https://213456423213456789456123ABCDEF.grx.us-east-1.eks.amazonaws.com
  config: |
    {
      "execProviderConfig": {
        "command": "k8s-auth-gke-wli-eks",
        "args": [
            "-rolearn",
            "arn:aws:iam::123456789012:role/argocdrole",
            "-cluster",
            "my-eks-cluster-name",
            "-stsregion",
            "us-east-2"
        ],
        "apiVersion": "client.authentication.k8s.io/v1beta1",
        "installHint": "k8s-auth-gke-wli-eks missing"
      },
      "tlsClientConfig": {
        "insecure": false,
        "caData": "base64_encoded_ca_data"
      }
    }

Features

The output of the program is an ExecCredential object of the client.authentication.k8s.io/v1beta1 Kubernetes API that is consumed by ArgoCD when authenticating EKS cluster.

Contributing

If you'd like to contribute to this project, please follow the standard open-source contribution guidelines. Please report issues, submit feature requests, or create pull requests to improve the application.

Additional resources

  • Terraform GKE Worload identity module: terraform-google-workload-identity
  • Available keys for AWS web identity federation, for example of role trust with accounts.google.com. AWS docs link
  • How to use trust policies with IAM roles, for ways to futher secure AWS trust policies. AWS Blog

Credits

License

This project is licensed under the MIT License - see the LICENSE file for details.

argocd-k8s-auth-gke-wli-eks's People

Contributors

dependabot[bot] avatar zepellin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.