Commit Graph
20 Commits
Author SHA1 Message Date
Simone Primarosa 5a8ffd0272 feat(eks): implement pod identity association management (#4012)
* feat(eks): implement pod identity association management

* fix(eks): use instance SecureRandom for native image compatibility
2026-09-20 17:54:41 -04:00
Simone Primarosa aede31c99c fix(eks): store and return encryptionConfig and logging on clusters (#4007)
* fix(eks): store and return encryptionConfig and logging on clusters

* docs(eks): retain access policies in unsupported features list
2026-09-20 12:40:42 -04:00
Simone Primarosa 51467dbc23 fix(eks): populate clusterSecurityGroupId on cluster responses (#3924)
* fix(eks): populate clusterSecurityGroupId on cluster responses

Real AWS EKS automatically provisions a cluster security group and
returns its identifier in resourcesVpcConfig.clusterSecurityGroupId
on CreateCluster and DescribeCluster responses.

- Create a security group in Ec2Service with the pattern
  eks-cluster-sg-<cluster-name>-<suffix> using 8 hex characters.
- Set standard AWS description and tags (Name, kubernetes.io/cluster/<cluster-name>,
  and aws:eks:cluster-name).
- Set clusterSecurityGroupId to empty string when cluster has no VPC.
- Delete the cluster security group on DeleteCluster, tolerating
  InvalidGroup.NotFound for idempotency.
- Backfill cluster security groups for pre-existing clusters on startup.

* fix(eks): address cluster security group review feedback

* fix(eks): add self-referencing egress rule and cleanup on SG setup failure
2026-09-20 08:52:40 -04:00
Simone Primarosa 0f6b5ee3a2 feat(eks): sign k3s service account tokens with the cluster OIDC key (#3783)
* feat(eks): sign k3s service account tokens with the cluster OIDC key

In real EKS, workloads authenticate via IAM Roles for Service Accounts (IRSA) using projected tokens signed by the cluster OIDC key with audience sts.amazonaws.com. In Floci, k3s launches with default signing flags, meaning it signs in-cluster pod tokens using its own internal auto-generated key under https://kubernetes.default.svc.cluster.local. Because Floci STS verifies tokens against Floci's per-cluster OIDC key and issuer, in-cluster pod tokens cannot be verified, forcing local workloads to use static credentials instead of IRSA.

To bridge this gap, Floci now passes the cluster's per-cluster OIDC keypair and issuer to the k3s container on cluster start and restore. EksClusterManager exports the cluster keypair as restrictive PEM files (0600) into /etc/rancher/k3s/ and configures kube-apiserver with signing keys, dual issuers, and dual audiences (https://kubernetes.default.svc.cluster.local and sts.amazonaws.com). Projected pod tokens now verify cleanly against Floci STS, while internal cluster components continue operating without disruption.

* fix(eks): isolate IRSA signing key files by account and region

Persist cluster OIDC signing keypairs under dataPath/keys/<accountId>/<region>/<clusterName> instead of only clusterName. Because EKS cluster names are unique only within an account and region, same-named clusters across different accounts or regions previously shared host key files, risking key overwrite during startup or restore.

* fix(eks): create signing key files with atomic owner-only permissions

Create the signing key and public key files with PosixFilePermissions rw------- atomically on creation via Files.createFile, avoiding any brief window where private key material is readable with default umask permissions.

* fix(eks): guard webhookPath against null cluster ARN and createdAt

Safely resolve accountId, region, and createdAt with fallbacks in webhookPath when cluster fields are null, and ensure integration tests populate cluster ARN and createdAt.
2026-09-18 17:22:12 -04:00
luiseterc fdec637c27 fix(eks): preserve worker webhook scope in the URL path (#3849)
* fix(eks): preserve worker webhook scope in the URL path

* docs(eks): clarify scoped and legacy webhook routes
2026-09-18 09:35:00 -04:00
luiseterc 6b389c33eb feat(eks): authenticate EC2 workers through access entries (#3805) 2026-09-17 10:09:21 -04:00
luiseterc 98c47c4347 feat(eks): implement access-entry management (#3745)
* feat(eks): implement access-entry management

* test(eks): wait for cluster activation in access-entry compatibility test

* fix(eks): validate access-entry maxResults with shared parser
2026-09-16 18:50:39 -04:00
Simone Primarosa a2fddaf08d feat(eks): expose IMDS on 169.254.169.254 inside cluster containers (#3693)
* feat(eks): expose IMDS on 169.254.169.254 inside cluster containers

When applications or agents run on Kubernetes nodes or use hostNetwork: true, they expect the AWS Instance Metadata Service (IMDS) at the standard link-local address 169.254.169.254:80. In Floci, EKS k3s cluster containers lacked access to IMDS at this link-local address, preventing workloads from discovering instance identities, node IAM roles, or dynamic cluster credentials without custom endpoint overrides.

This change exposes IMDS on 169.254.169.254:80 inside EKS cluster containers when floci.services.eks.imds is enabled. It configures a background TCP relay via socat pointing to the host's EC2 metadata port, registers a synthesized EC2 node instance with the cluster's IAM role and container IP in Ec2MetadataServer, extracts reusable metadata proxy logic into Ec2MetadataProxy, and documents node network namespace reachability and hop limit handling.

* fix(eks): address review feedback on lifecycle check, default flag, and instance seed

* fix(eks): synthesize distinct node instance profile and import CompletableFuture

* test(eks): enable IMDS profile and provide curl in docker test fixture
2026-09-16 11:33:39 -04:00
Simone Primarosa 95079965a8 fix(ecr): enforce immutable image tags (#3009)
Route Docker Distribution traffic through Floci so repository mutability applies to manifest writes. Keep legacy registry storage reachable while moving public ECR endpoints to the guarded listener.
2026-09-14 12:07:40 -04:00
BingEdward 90fa707145 fix(sts): return ExpiredTokenException for an expired web identity token (#3210)
* fix(sts): return ExpiredTokenException for an expired web identity token

AssumeRoleWithWebIdentity mapped every WebIdentityTokenVerifier failure to
InvalidIdentityToken, so an expired but otherwise valid IRSA token got the
same wire error as a bad signature or wrong issuer. Real STS reports the
expiry case as ExpiredTokenException so callers can refresh and retry.

Fixes #3205

* test(eks): inject EksOidcService through the test constructor
2026-09-07 21:43:46 -05:00
Simone Primarosa 309043baf6 fix(eks): validate IAM authentication tokens (#2912)
Reject forged, expired, and cross-cluster EKS authentication tokens before granting cluster-admin access.
2026-09-02 19:37:26 -04:00
Matheus André eaecb36425 fix(eks): implement cluster restoration after restart to maintain state (#2780)
Signed-off-by: Matheus André <matheusandr2@gmail.com>
2026-08-30 14:44:05 -05:00
Miguel Carvalho 7e5afae61b feat(eks): support IRSA with a real OIDC issuer and JWT validation (#2108)
* feat(eks): support IRSA with a real OIDC issuer and JWT validation

Every EKS cluster now gets an OIDC identity provider, so the full IRSA flow
works end to end without mocked or hardcoded tokens.

CreateCluster generates an RSA-2048 keypair and an AWS-shaped issuer URL,
returned by DescribeCluster as identity.oidc.issuer. The issuer is a faithful
string for building trust policies but is never dereferenced: STS resolves the
signing key in-process via a new OidcIssuerKeyLookup port, declared in
core.common so services.iam does not depend on services.eks.

Key material lives in storage separate from the Cluster model. Cluster is
serialized straight onto the DescribeCluster wire response, so a private key
carried there would leak; @JsonIgnore would instead lose it across restarts and
break tokens minted earlier.

sts:AssumeRoleWithWebIdentity previously accepted any non-blank token and
returned a hardcoded subject. It now verifies, but only for issuers Floci hosts:

- RS256 signature against the cluster's public key
- iss matches the issuer exactly
- aud contains sts.amazonaws.com
- exp / nbf, with 60s of clock-skew tolerance
- the role's trust policy, via a new WebIdentityTrustPolicyEvaluator matching
  Principal.Federated and the Condition block

The response now carries the token's real claims in
SubjectFromWebIdentityToken, Provider, and Audience. Bad tokens return
InvalidIdentityToken (400); a trust policy that does not permit the subject
returns AccessDenied (403) — a check the web-identity path was missing entirely.

Tokens from an issuer Floci does not host stay permissive, since Floci cannot
verify a third-party signature. Existing behaviour is therefore unchanged and no
configuration flag is required.

WebIdentityTrustPolicyEvaluator is a sibling of AssumeRolePolicyEvaluator rather
than an extension of it: that evaluator serves sts:AssumeRole, hardcodes that
action, reads only Principal.AWS, and ignores conditions. Condition values are
compared with exact, case-sensitive equality instead of the existing
globMatches, which lowercases both operands — case-folding an OIDC subject would
silently admit a different service account.

Because Floci has no kubelet to project a token into a pod, a local-dev harness
can mint one via POST _floci/eks/clusters/{name}/oidc-token and write it to the
file named by AWS_WEB_IDENTITY_TOKEN_FILE. Signing stays server-side so the
private key never leaves Floci. OIDC discovery and JWKS routes are served under
the same _floci namespace, for fidelity rather than because anything fetches
them; the AWS-shaped issuer path is not resolvable by Floci's embedded DNS and
would collide with S3's path-style catch-all.

Adds 51 tests: unit coverage for the verifier, the trust-policy evaluator, and
the OIDC service, plus an end-to-end integration test covering the mint ->
assume -> credentials path and its negative cases (wrong service account,
tampered signature, wrong audience, expired, alg:none).

* fix(iam): close two web-identity validation gaps and backfill cluster OIDC state

Three defects found in review of the IRSA change.

An unsigned "header.payload." token bypassed validation entirely. verify()
split with a -1 limit so a trailing empty segment was preserved, but
parseClaims() — which backs peekIssuer() — did not. Java drops trailing empty
strings by default, so such a token split into two parts, its issuer went unseen,
and STS classified it as an opaque third-party token: signature, claim, and
trust-policy checks were all skipped and credentials were issued for a JWT that
was never signed. Both split sites now pass -1.

StringLike and StringNotLike on an OIDC condition key folded case. They
delegated to IamPolicyEvaluator.globMatches, which lowercases both operands, so
a trust policy scoped to one service account or namespace would admit another
differing only in case — the exact hazard the StringEquals branch was written to
avoid. Adds a case-sensitive glob and uses it for both operators. Action matching
still uses globMatches, which is correctly case-insensitive.

Clusters persisted before this feature never gained an issuer or key, so after an
upgrade DescribeCluster reported no identity.oidc.issuer, minting returned 400,
and the JWKS routes 404'd until the cluster was recreated. EksService now
backfills on startup, and re-runs ensureKey for clusters that already have an
issuer so a restart cannot leave a known issuer without its signing key.

Each fix has a regression test confirmed to fail without it.

* fix(eks): keep IRSA OIDC state scoped to the cluster's owning account

The startup backfill read clusters across every account via scanAllAccounts() but
wrote them back with the request-scoped put(), which resolves to the default
account outside a request context. A cluster owned by any other account kept its
issuer-less record while a duplicate appeared under the default account, leaving
DescribeCluster and the IRSA endpoints broken for the owner. The backfill now
takes the account from the cluster record and writes with putForAccount, per the
pattern StorageFactory documents for work running outside a request.

The same root cause affected key lookup more seriously. findVerificationKey used
the account-scoped scan(), so an issuer owned by a non-default account went
unresolved — and an unresolved issuer is treated as a third-party provider, so
STS accepted the token with no signature, claim, or trust-policy check at all.
It now scans every account, which is correct regardless: an issuer URL is
globally unique, and the account calling AssumeRoleWithWebIdentity need not be
the one that owns the cluster.

deleteKey and findKeyByCluster stay account-scoped; both are only reached from
request-scoped paths (DeleteCluster and the JWKS route), where the caller's
account is the right scope.

Both fixes have a regression test confirmed to fail without them.
2026-08-10 09:04:40 -04:00
Ioannis Lafiotis 095e167bae Nodegroups eks fargate eks (#1523)
* feat(eks): add nodegroups and fargate profiles

* docs: sync generated action tables
2026-07-15 01:03:24 -04:00
Hector Ventura 7586a01cf9 fix(eks): let pods pull images pushed to the Floci ECR registry (#1762)
k3s containerd could not reach the emulated ECR registry: repository
URIs embed localhost plus the host-published port, which resolves to the
k3s container itself, and containerd requires a registries.yaml entry
before it will speak plain HTTP to a registry.

New clusters now get a generated /etc/rancher/k3s/registries.yaml,
injected through the Docker API before the container starts, that
mirrors every repository hostname the emulator can mint (the default
account across the region catalog, plus the path-style form) to the
registry container's in-network endpoint. Public registries are never
matched, and any failure skips the mirror without aborting cluster
creation. Opt out with FLOCI_SERVICES_EKS_ECR_REGISTRY_MIRROR=false.

Closes #1761
2026-07-06 21:36:14 -05:00
Hector Ventura 7128758a63 feat(eks): make real-mode clusters reachable and authenticable from the host (#1167)
In real mode `aws eks create-cluster` brought up a k3s container that was
unreachable from the host and rejected every request with 401. This makes the
native AWS workflow work end to end (`aws eks update-kubeconfig` + `kubectl`).

- describe-cluster returns a host-reachable endpoint (https://localhost:<hostPort>),
  configurable via endpoint-mode (host|network), default host
- token-authentication webhook (POST /_floci/eks/token-webhook) validates the
  `aws eks get-token` bearer token and maps it to system:masters; pins the
  apiserver to the v1 TokenReview API and echoes the request apiVersion
- webhook kubeconfig is injected into k3s via the Docker API (create -> copy ->
  start), so it works in native and Docker-in-Docker with no host-path config
- k3s network falls back to the global docker-network, then auto-detected

Closes #1118
2026-06-04 00:42:25 -05:00
Hector Ventura 9e35046647 Docs/enviroment instead yml (#764)
* docs: moving all config to env instead of yml
* docs: sync with main and new features
* docs: reverting docker-compose.yml
2026-05-10 11:53:31 -05:00
Kenshin Okinaka 88f40a839b docs: update Docker image references to floci/floci (#595)
* docs: update Docker image references to floci/floci
* docs: keep README Docker Hub badges pointing to hectorvent/floci

The hectorvent/floci image has accumulated pull and size metrics; switch
the badges to floci/floci once the new image has comparable numbers.
2026-04-25 09:29:39 -05:00
Hector Ventura ee08d3ad44 feat(opensearch): add real os with docker image (#528)
* feat(opensearch): add real os with docker image
* fix: fix opensearch network issue
2026-04-19 19:04:31 -05:00
Hector Ventura 63ed81c59d feat(eks): implement EKS service with real k3s data plane support (#493)
* feat(eks): implement EKS service with real k3s data plane support
* fix: adjusting eks volume issues
2026-04-18 01:35:25 -05:00