The Pod Identity webhook manifest carried only Floci's local CA, so with
floci.tls.cert-path set the API server refused Floci's certificate, and
failurePolicy Ignore admitted every pod unchanged. Its URL named the
Docker host: with Floci in a container that is Floci's container IP,
which Floci's own certificate does not name. An adopted cluster also
kept the manifest written when its container was created.
The caBundle is now the bundle /_floci/ca.pem serves, which moves into
ContainerCaBundle so both read it from one place. The URL uses a host
the served certificate names, through the check custom resource response
URLs already make in ContainerReachableEndpoint: Floci's hostname when
the node resolves through Floci's embedded DNS, otherwise the Docker
host. When the certificate does not name that host, the webhook is
skipped with a warning, as it is with TLS off. Adopting a surviving
cluster writes the manifest again, and names Floci's hostname only when
the surviving node was created with Floci's DNS server as its resolver.
The manifest and the webhook k3s registered from it live on the
cluster's data volume, so a skipped webhook now replaces the manifest
with one holding no objects, and k3s deletes the webhook an earlier
start registered.
The manager's constructors that left collaborators out existed only for
tests; they move to a test-side factory, so the endpoint the webhook
needs is never null in production code.
Closes#5563
Co-authored-by: Andre Kurait <AndreKurait@gmail.com>
A managed node group created without a releaseVersion reported
<version>-eks-1, while AWS reports the release of its AMI in the
<patch version>-<build date> shape SSM publishes under
recommended/release_version. The release is now built in one place,
EksAmiReleaseVersions, which SSM and EKS both call, from the recommended
EKS optimized AMI the image catalog holds for the node group's Kubernetes
version and AMI type (AL2_x86_64, AL2023_x86_64_STANDARD,
AL2023_ARM_64_STANDARD).
A node group whose launch template names a custom AMI reports that AMI id,
as the Nodegroup reference describes; an explicit releaseVersion is still
echoed, and an AMI type the catalog has no recommended AMI for keeps
<version>-eks-1.
Floci now implements UpdateClusterConfig for endpoint public and private access, publicAccessCidrs, logging and authentication mode, each stored as an update DescribeUpdate returns. As on EKS, one request names one family, the authentication mode moves one step forward (CONFIG_MAP, API_AND_CONFIG_MAP, API), turning both endpoints off or sending an endpoint or logging update that changes nothing is refused with EKS's messages, and a repeated clientRequestToken returns the first update. A different subnet or security group list, and any other member, the Auto Mode ones included, are refused. DescribeUpdate with an addonName no longer answers a cluster update.
* feat(eks): accept EKS Auto Mode's cluster configuration
* fix(eks): create Auto Mode clusters from CloudFormation, refuse a lone node role
* fix(eks): leave EKS Auto Mode out of AWS::EKS::Cluster until step 2
FLOCI_SERVICES_IAM_SEED_DEPLOYER_ACCESS_KEY_ID (floci.services.iam.seed-deployer-access-key-id) chooses the seeded deployer's access key ID. The default stays floci, so setups signing with floci / floci keep working; any other value must be 16 to 128 word characters, as IAM requires of an AccessKeyId, or startup fails naming the setting. With such an ID the deployer's key can be deactivated and deleted, and then the floci-deployer user. Under persistent storage, seeding deletes the deployer's key seeded under an earlier ID, the one signing with the public floci secret, and keeps keys made with CreateAccessKey. The EKS token webhook refuses the seeded credential by that public secret rather than by its access key ID.
Closes#8624
Pods resolve through CoreDNS, which forwards to the resolver file k3s
hands them. k3s takes the node's /etc/resolv.conf, and on a user-defined
Docker network that names only Docker's loopback 127.0.0.11, which k3s
refuses; it then writes a file naming a public resolver. So Route 53
private zones, Cloud Map names and the other names only Floci answers
never resolved from a pod.
When embedded DNS is on and running, and the cluster's Docker network
can reach it, Floci now copies a resolver file naming only its DNS
server into the cluster container before it starts, and passes it to
k3s with --resolv-conf. With Floci in a container that means the
cluster is on Floci's own network: Docker isolates user-defined
networks, and pods given only an unreachable resolver would lose the
public one too. The public fallback resolvers
stay out of it, because CoreDNS picks among its upstreams at random. A
cluster that sets the kubelet's resolv-conf through its tags keeps its
own file. A file that cannot be copied fails the start, as a container
that cannot start does, since k3s would hand its pods a missing file.
* fix(eks): answer IMDS on a node by NAT rules instead of a socat relay
* fix(eks): refuse a pod's IMDS request without the pod network, and probe the instance id
Every Service Matrix row now has its operation count checked, or a stated
reason it cannot be. The REST rows map their JAX-RS controllers in
action_count_sources, with:
- rename_actions for a method not named after its AWS action, and a list
for a method that answers several actions by query parameter
(CreateRestApi and ImportRestApi on POST /restapis?mode=import)
- route_prefix and skip_route_prefix on a REST source, so API Gateway's v1
and v2 rows split the one controller that serves both
- a tag_handler source mode: a TagHandler class is what gives a service the
three tagging actions the shared /tags controllers serve
- exclude_actions for operations that always fail (InvokeModelWithResponseStream
answers 501, ExecuteSql BadRequestException, Amazon MQ's user calls
BadRequestException for RabbitMQ brokers)
A new coverage gate fails when a row is neither checked nor listed under
hand_counted with its reason, when two rows share a link target, or when a
row has no numeric count. It replaces the required-sources list. S3 is the
one hand-counted row: its handlers pick most operations by query string.
Most REST rows were undercounted, EKS by the most (7, served 35). IoT Data
gets its own anchor, as it shared iot.md with IoT Core and its count was
never read. The AppSync, CloudFront, EKS, Lambda and Pipes pages now list
the operations their controllers serve: AppSync's listed names that do not
exist, and CloudFront's called stored-only operations unsupported.
Closes#4999
A stock rancher/k3s node has no package manager, so the socat relay Floci installed for the EKS Pod Identity address, 169.254.170.23, never started, and every pod's credentials request timed out. The address is now sent straight to Floci's credentials endpoint with iptables NAT rules, a PREROUTING rule for the pod network and an OUTPUT rule for the node and hostNetwork pods, and what an older Floci set up for the address, its relay included, is removed. The rules follow the eks-pod-identity-agent add-on: CreateAddon adds them, DeleteAddon removes them unless preserve is set, and a node start or a restart's adoption sets them from the stored add-on, under a lock of the cluster. The Pod Identity webhook reads the same stored add-on.
Closes#5629
Deleting an EKS add-on or Fargate profile now keeps only its ARN for
IAM authorization, keyed by the cluster's incarnation, so a deletion
waiter with a resource-scoped describe grant receives
ResourceNotFoundException instead of AccessDeniedException, while an
unrelated grant or an explicit deny still gets 403. Describe and list
still report the resource as gone, recreation clears the kept ARN and
cluster deletion purges it. Resource tags are not kept.
Closes#8494
* refactor(autoscaling): register target group members next to their deregistration
* feat(autoscaling): keep the groups EKS manages for its node groups
* feat(eks): give each managed node group the Auto Scaling group it reports
* refactor(autoscaling): build groups and read a Region's groups through shared helpers
* fix(autoscaling): change an EKS group's node and target groups under the Region's lock
* fix(autoscaling): refuse moving or replacing an EKS group's node
* fix(eks): create a node group's Auto Scaling group once, and delete the others past a failure
* docs(eks): what an EKS node group's Auto Scaling group allows, and what ordinary groups register
* fix(autoscaling): keep an EKS group's target group attached when ELBv2 refuses to deregister its node
* test(eks): build the node group Auto Scaling tests' EKS requests with one EksRequests helper
* test(eks): build the access entry, add-on, Pod Identity and Region scoping tests' EKS requests with EksRequests
* test: read a target group's registered targets with one AlbFixtures.targetIds
* test(autoscaling): match a single deregistered or registered target with one onlyTarget matcher
* test(autoscaling): delete a group sharing the node through EKS and through Auto Scaling in one test
* perf(eks): read only the registering node's cluster when adding it to its node groups' Auto Scaling groups
* docs(autoscaling): say an EKS group's node is registered with an elbv2 traffic source
* fix(eks): keep a cluster's API server port when its container is recreated
* fix(eks): leave a network-mode endpoint's port out of the restored port
* fix(eks): free an unadoptable survivor's port first, and tell a taken port from an error
Cluster names only have to be unique within a Region of an account, but
EKS stored clusters under the bare name, so creating `demo` in
eu-central-1 failed with ResourceInUseException while a `demo` existed in
eu-west-1. Since #7936 the eu-central-1 caller cannot even see that
cluster.
Clusters, node groups and Fargate profiles are now keyed by
`<region>::<name>`, as OpenSearch domains and Kinesis streams are, and so
are the node-capacity locks and the OIDC signing keys. On startup,
records persisted under the bare name move to the new keys, taking the
Region from each record's ARN. A cluster's signing key moves with it, so
tokens it signed before the upgrade still verify. Access entries, add-ons
and Pod Identity associations were already keyed by the cluster ARN.
A cluster outside the default Region, or one that shares its name with a
cluster in another Region, puts its Region first in its Docker container
and volume names. This is persisted as dockerNameRegion and left out of
API responses, so two Regions' clusters never share a k3s container. A
default-Region cluster, and any cluster created before this change, keeps
its name, so existing containers, volumes and endpoint-mode=network DNS
names stay as they are.
The Pod Identity webhook path now includes the Region. The old path still
works for clusters whose webhook configuration predates the change. The
_floci OIDC routes have no Region of their own and are usually called
unsigned, so they try the request's Region and then the account's only
cluster with that name.
Closes#7966
Follow-up to the Regional cluster names change, from review:
- k3s was given a signing key minted under the bare cluster name while
EksService created, published and migrated the cluster's key under its
Regional key, so pod tokens could be signed with a key JWKS did not
publish. EksClusterManager now asks for the key by the Regional key, at
start and on reinjection.
- The token-webhook kubeconfig, audit policy, registries.yaml and Pod
Identity manifest Floci writes per cluster now live under
<kind>/<account>/<region>/<name>/, the layout of the signing-key files,
so same-named clusters in two Regions no longer share them.
- The Region-less Pod Identity webhook route resolves the cluster created
before Regional names, which registered it, rather than preferring the
request's Region, which could pick a newer same-named default-Region
cluster.
- OIDC discovery and the key route take an optional region query
parameter, and the discovery document's jwks_uri names the cluster's
Region, since a verifier follows it without the discovery context.
- A signing key stored before account-prefixed keys now moves with its
cluster too, checked by its issuer.
- CreateCluster reserves the Regional key until the cluster is stored, so
a concurrent create of the same name in the same Region is refused
instead of overwriting the first.
- Test imports replace fully qualified names, for Checkstyle.
Cluster names are unique only within a Region of an account, and the
token route is usually called unsigned, so with the same name in two
Regions it could only mint for the request's Region. Accept the same
optional ?region= as the discovery and key routes, and document it.
Also correct the accountQualifiedName Javadoc, which still said names
are unique only within an account.
* fix(eks): page ListClusters with maxResults and nextToken
ListClusters returned every cluster in one response and ignored both
pagination parameters. It now returns cluster names in a stable order,
at most maxResults per page (default and maximum 100), with a nextToken
on every page but the last. A maxResults outside 1 to 100 or an
unreadable nextToken is refused with InvalidParameterException, as EKS
does.
Fixes#7625
* fix(eks): bind ListClusters tokens to the calling account
A nextToken issued in one account was accepted in another and skipped
the cluster names that sort before its cursor. The token now carries the
account it was issued to, and another account refuses it with
InvalidParameterException. The pagination tests also get distinct
@Order values.
* fix(eks): reuse the access entries page-size check in ListClusters
ListClusters repeated the 1 to 100 maxResults check that
EksAccessEntryService.pageSize already makes. That method is now
package-private and ListClusters calls it.
* fix(eks): let guest kubelet own worker node registration
Honor an explicit image catalog capability on initial join and replay. Preserve simulated registration by default and retain join bookkeeping and listeners.
Closesfloci-io/floci#7419
* test(eks): clean up the kubelet registration worker independently
Retain the launched instance ID and terminate it in the original account and region. Attempt worker, tracking and cluster cleanup independently and verify the worker reaches terminated state.
AssociateAccessPolicy, ListAssociatedAccessPolicies and
DisassociateAccessPolicy had no route, so their requests fell through to
S3's path-style catch-all and came back as an S3 XML error. Terraform's
aws_eks_access_policy_association could not be created.
The three operations follow access entries: they are management
metadata, stored and returned but not enforced in Kubernetes. Each
association is kept on its access entry, so deleting the entry or the
cluster removes it, and entries persisted before this change load with
no policies. ListAccessEntries now honours associatedPolicyArn.
Validation follows the EKS user guide: only STANDARD entries take access
policies, the scope is cluster (no namespaces) or namespace (one or more
names, wildcards kept, a repeated name stored once), and associating a
policy again replaces its scope and keeps its associatedAt. policyArn
must be an EKS cluster access policy ARN in the cluster's partition; the
name is not checked against AWS's list. Listing pages from 1 to 100,
with tokens bound to the entry they came from. Disassociating a policy
the entry does not hold succeeds, since EKS documents no error for it;
a missing entry is still ResourceNotFoundException, and an ARN that
associate would refuse is InvalidParameterException. ListAccessEntries
now pages through the shared Pagination helper too, so a token issued
before this change is refused.
Under IAM enforcement the list and disassociate routes were checked as
DescribeAccessEntry and DeleteAccessEntry, and all three against a
principal ending in /access-policies, so a grant scoped to the entry
never matched. They are now checked as their own actions, against the
entry's ARN.
A DELETE is a disassociate only when a cluster access policy ARN
follows access-policies, in the route, the IAM rule and the resource,
so an entry whose IAM path holds an access-policies segment can still
be deleted. The router matches the encoded path, so a principal sent
URL-encoded, as the SDKs send it, is never split.
Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
endpoint-mode=host always returned https://localhost:<port>, so a cluster
was only usable from the machine running Floci. The new
floci.services.eks.endpoint-host (FLOCI_SERVICES_EKS_ENDPOINT_HOST) is
advertised instead, and added to the k3s certificate as a SAN so the
endpoint still verifies against the cluster CA. It follows rds.endpoint-host.
The value must be a DNS name, a dotted IPv4 address or an IPv6 address;
an IPv6 literal is bracketed in the endpoint URL. A scheme, port, path or
list stops Floci at startup, before persisted clusters are restored, so a
typo cannot leave every restored cluster FAILED.
Network mode inside a container advertises the container name, so it
ignores the setting.
The SAN is fixed when the container is created, so the container carries
the host it was made for as a label, and an adopted container advertises
that host rather than the configured one. When the two differ on restore,
the surviving container is replaced (data volume and port kept), as a
node-capacity change already does; if the replacement fails, the old
container stays and keeps advertising the host its certificate carries.
Unset, nothing changes: no label is added and existing containers are
adopted as before.
Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
* fix(eks): accept a role ARN from another partition the way STS does
An account keeps one IAM namespace whichever partition a request is for
(partitions.md, Known gaps). STS AssumeRole already resolved a role ARN
from another partition to the account's role, while EKS Pod Identity and
add-ons required the cluster's partition and an exact stored-ARN match.
Move the STS role-ARN matcher to IamService.roleArnMatches and use it for
the Pod Identity roleArn and the add-on role ARNs; targetRoleArn accepts
any well-formed partition. The Pod Identity session names the stored
role's ARN, as an STS session does. The EKS model sets no pattern on
roleArn or targetRoleArn.
* fix(eks): keep a role recreated under another path out of a pod identity session
The credentials endpoint finds the association's role by name only. Since
the session started naming the stored role's ARN, a role deleted and
recreated under another path gave the session its ARN and role id through
the old association. The found role now has to match the association's
role ARN the way roleArnMatches does everywhere else; one that does not is
treated as absent, as before this branch.
The association test also checks that a rejected role update leaves the
stored role ARN as it was.
* fix(eks): refuse pod identity credentials when the association's role is gone
EKS Auth assumes the association's role through STS, so a role that no
longer exists gets no credentials. The endpoint still issued them, and
since enforcement loads a session's policies by role name, a pod whose
role was recreated under another path ran with the replacement's policies.
A role that is missing, or that does not match the association's role ARN,
is now a 400 AccessDeniedException and no session is registered.
The k3s registries.yaml listed the default account across the regions of
the deployment's partition, so a cluster in another account, or in a region
of another partition served by the same process, could not pull from
Floci's ECR through its own repository hostnames.
Build the mirror from the cluster's account (then the default account)
across every region of the cluster's partition. A commercial cluster in
the default account gets the same file as before.
ECR built repositoryUri, the GetAuthorizationToken proxyEndpoint and
the Lambda and ECS image rewrites from floci.port, the port Floci
listens on inside its own container. The Docker daemon performs login,
push and pull, and reaches Floci through the host port that container
publishes. When Floci ran as docker run -p 54321:4566, every advertised
address named port 4566 on the host, where nothing answers, so docker
login, CDK container asset publishing and ECS or Lambda image pulls
failed.
EcrRegistryManager now has advertisedPort(): the host port Floci's
container publishes for floci.port, read through the existing
CurrentContainerNetworkResolver.resolvePublishedPort as RDS does for
its proxy endpoint, or floci.port when Floci is not in a container or
the port is not published. repositoryUri (hostname and path style,
plain and TLS URI mode), proxyEndpoint and rewriteImageUri all use it.
The EKS registry mirror keys must match the URIs pods name, so they
use the same advertised port. The mirror endpoint stays Floci's
in-network address on floci.port.
The resolver now caches every published-port answer, "not published"
and a failed inspect included, as it already caches the network: a
running container's port bindings cannot change, and an inspect that
fails fails the same way next time. ECR requests therefore do not
inspect the container each time.
Support joining real EC2 instances to an EKS cluster as Kubernetes nodes.
Inspect instance user data during RunInstances for bootstrap scripts or
nodeadm YAML targeting an EKS cluster, recording pending joins and
reconciling node registration asynchronously via the readiness poller.
Ensure RunInstances returns without blocking on kubectl or shared locks,
and guard storage mutations under the deletion lock so deleted clusters
cannot be resurrected. Scope restoration tracking per account.
Support AL2023 MIME multipart nodeadm configurations, and share the
in-use IP check and cursor loop between subnet and subnetless launches.
Update node metadata derivation to match AWS conventions, using instance
private DNS names for node names and aws:///<az>/<instance-id> for
provider IDs, with topology and instance-type labels.
* feat(eks): apply nodegroup labels, taints and capacity type to the node
* fix(eks): address review feedback on nodegroup metadata injection
* fix(docs): sync IAM operation count in service matrix
* fix(eks): use single string literals without concatenation in log messages
* chore(eks): resolve phantom nodegroup review finding
* docs(eks): document CAPACITY_BLOCK capacity type for nodegroups
* feat(eks): stop shipping a default storage class in clusters
* test(eks): verify coredns rollout status and preserve cluster storage on restore
* test(eks): assert storage class absence after coredns rollout completes
* docs(eks): clarify stock storage class and provisioner behavior
The EKS token webhook looked long-term keys up through findSecretKey,
which is account-scoped. k3s calls the webhook with no account routing,
so it saw only the default account's keys. A correctly signed
`aws eks get-token` from a user in any other account was rejected:
kubectl reported "the server has asked for the client to provide
credentials".
The webhook now uses a new IamService.findSecretKeyInAnyAccount. It
tries the request's account first and scans the other accounts only on
a miss. Inactive keys are still refused, and temporary (ASIA) keys never
reach the scan. findSecretKey itself stays account-scoped: the
ElastiCache, MemoryDB and RDS IAM-auth proxies verify through it and do
not compare the key's account with the cluster's.
Because a long-term key can now reach the webhook from any account, the
legacy identity (system:masters) is limited to long-term keys owned by the
cluster's account, or by the default account on unscoped webhook paths
that predate per-account clusters. This also tightens one existing case:
a default-account key used to get system:masters on clusters of every
account, and now gets it only on the default account's clusters.
Session credentials without an instance ID still map to the legacy
identity on any cluster; that predates this change and is left alone.
Co-authored-by: Robin Baeckman <27041454+RobinBaeckman@users.noreply.github.com>
* feat(eks): name cluster nodes after their EC2 instance
* fix(eks): prune legacy hostname nodes on finalize and test container recreation
* fix(eks): preserve active nodes when pruning legacy cluster nodes
* fix(eks): delimit jsonpath node records with newline outside condition range
* fix(eks): name nodes using EC2 private DNS name format and align synthetic instance
* fix(eks): implement DnsRecordSource to resolve node private DNS names
* fix(eks): prevent VPC forwarding rules from bypassing node private DNS resolution
* fix(eks): scope node DNS system rules to matching VPC only
* feat(eks): support per-cluster kubelet and API server arguments
* fix(eks): prevent security group leak and reject authorization-mode override
* refactor(eks): classify authorization-mode as refused argument
* fix(eks): strip modifier suffixes before collision validation
* feat(eks): bound cluster node capacity and reserve kubelet resources
* fix(eks): use the large managed node pod cap
* fix(eks): preserve node capacity through restart failures and restores
* fix(eks): retain restored node until capacity replacement starts
* fix(eks): let concurrent node groups share user data execution
* fix(eks): finalize first node group after bootstrap
* fix(eks): retain restored replacement when backup cleanup fails
* fix(eks): stop live node before retrying backup cleanup
* ci: retry transient mqtt port collision
* fix(eks): preserve cluster API port during node capacity change
* test(docker): verify exec attach stream closes on timeout
* fix(eks): keep capacity backup names outside cluster namespace
Program static kernel routes in EKS cluster containers from emulated
VPC route tables associated with the cluster subnets or VPC.
- Implement route table resolution for cluster VPC and subnets
- Resolve EC2 instance and network interface targets to reachable IPs
- Generate idempotent routing shell commands using ip route
- Attach cluster containers to the VPC bridge network when present
- Notify active clusters on route table modifications via VpcRouteTableListener
- Add configuration flag floci.services.eks.vpc-route-programming
- Add unit and Docker integration tests for route programming
Implement DnsRecordSource SPI via Route53DnsRecordSource to decouple Route 53 resolution from EmbeddedDnsServer. Add DnsLookupHelper in core.common.dns for external IPv4 resolution via upstream forwarders with system fallback, shared by Route53DnsRecordSource for CNAME and ALIAS chasing. Discover private hosted zones via Route53Service and support in-zone chasing, built-in Floci suffixes, and EC2 internal names. Authoritatively resolve A records within private zones to prevent upstream query leakage. Wire EKS cluster containers to embedded DNS via specBuilder.withEmbeddedDns().
* feat(ec2): expose synthesized cluster node instances to the EC2 service
* fix(ec2): enforce account isolation and tag persistence for cluster node instances
* fix(ec2): scope findInstanceById to caller account for external instances
Scope findInstanceById to the caller account when falling back to
external instances instead of matching across all accounts. Thread
the account identifier into SSM direct command execution, ELBv2 target
resolution, and classic ELB health checking so external cluster nodes
remain strictly account-isolated across all instance lookup paths.
* fix(ssm,eks): update test stubs for account-scoped direct execution and harden cluster provider
Validate node group launchTemplate specifications against EC2 during
CreateNodegroup. Reject requests where neither or both of id and name
are supplied, or where the referenced launch template or version does
not resolve in EC2, with InvalidParameterException (400). Resolve
launch templates and construct nodegroup ARNs using the cluster's region
rather than the default region.
* feat(eks): serve pod identity credentials on 169.254.170.23
* fix(eks): safely handle cluster arn and initialize test cluster in pod identity integration test
* test(eks): configure fixed test port for pod identity docker integration test
* fix(eks): isolate pod routing and restore webhook timeout