This page describes the security features included in
GKE on AWS, including each layer of its infrastructure, and
how you can configure security features to suit your needs.

## Overview

GKE on AWS offers several features to help secure your [workloads](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/deploying-workloads-overview),
including the contents of your container image, the container runtime, the
cluster network, and access to the cluster API server.

It's best to take a layered approach to protecting your clusters and workloads.
You can apply the [principle of least privilege](https://en.wikipedia.org/wiki/Principle_of_least_privilege) to the level of
access you provide to your users and workloads. You might need to make tradeoffs
to allow the right level of flexibility and security.

## Shared responsibilities

When you use GKE on AWS, you agree to take on certain
responsibilities for your clusters. For more information, see
[GKE clusters shared responsibilities](https://docs.cloud.google.com/anthos/docs/concepts/gke-shared-responsibility).

## Authentication and authorization

You authenticate to an GKE on AWS user cluster through one of the
following methods:

- Using the [`anthos-gke`](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/creating-user-cluster.md.txt#authenticate) tool.
- Using a Kubernetes Service Account token with the [Google Cloud console](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/connecting-to-a-cluster.md.txt).
- Using [Open-ID Connect (OIDC)](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/oidc.md.txt).

To configure more granular access to Kubernetes resources at the cluster level
or within Kubernetes namespaces, you use Kubernetes
[Role-based access control (RBAC)](https://docs.cloud.google.com/kubernetes-engine/docs/how-to/role-based-access-control.md.txt).
RBAC lets you create detailed policies to define which operations and
resources you allow users and service accounts to access. With RBAC, you
can control access for any validated identity provided.

To further simplify and streamline your authentication and
authorization strategy for Kubernetes Engine, GKE on AWS disables
[Legacy attribute-based access Control (ABAC)](https://docs.cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.zones.clusters.md.txt#LegacyAbac).

## Encryption

By default, GKE on AWS encrypts
[data in `etcd` at rest](https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/), EBS volumes, Kubernetes Secrets, and
[control plane components](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/concepts/security.md.txt#control-plane) with the
[AWS Key Management Service (KMS)](https://aws.amazon.com/kms/).

To encrypt sensitive data in your user clusters, you can use one of the
following:

- Kubernetes Secrets
- [Hashicorp Vault](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/secrets-with-vault.md.txt)

### Kubernetes Secrets

Kubernetes [Secrets](https://kubernetes.io/docs/concepts/configuration/secret/)
resources store sensitive data, such as passwords, OAuth
tokens, and SSH keys, in your clusters. Storing sensitive data in Secrets is
more secure than storing them in plaintext
[ConfigMaps](https://kubernetes.io/docs/concepts/configuration/configmap/)
or in Pod
specifications. Using Secrets gives you control over how sensitive data is used,
and reduces the risk of exposing the data to unauthorized users.

### Hashicorp Vault

GKE on AWS can use
[Hashicorp Vault](https://www.vaultproject.io/) to
secure Secrets on your user clusters.
See [Using HashiCorp Vault on GKE on AWS](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/secrets-with-vault.md.txt)
for more information.

## Control plane security

The control plane components include the management service and the user
cluster's Kubernetes API server, scheduler, controllers, and the
[etcd database](https://github.com/coreos/etcd). In GKE on AWS, local administrators
manage the control plane components.

In GKE on AWS, the control plane components run on AWS. You can
protect GKE on AWS's API server by using AWS security groups and
network ACLs.

All communication in GKE on AWS is over Transport Layer Security
(TLS) channels governed by the following certificate authorities (CAs):

- The etcd CA secures communication from the API server to the etcd replicas and also traffic between etcd replicas. This CA is self-signed.
- The user cluster CA secures communication between the API server and all internal Kubernetes API clients (kubelets, controllers, schedulers). This CA is KMS encrypted.
- The management service CA is AWS KMS encrypted. It is created when you run `anthos-gke init` and stored in your Terraform workspace. When you use `terraform apply` to create the management service, the CA key is passed as AWS EC2 [user data](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html) and decrypted by AWS KMS when the cluster starts.

For the management service, control plane keys are stored on control plane
\[nodes\]{:.external}. For user clusters, the keys are stored as Kubernetes
Secrets in the management service's control plane.

Cluster authentication in GKE on AWS is handled by certificates
and service account bearer tokens. As the administrator, you authenticate to the
control plane using with the administrative certificate to the management
service (which you use for initial role binding creation, or for emergency
purposes).

Certificate rotation is handled in the following ways:

- For the API server, control planes, and nodes, GKE on AWS rotates TLS certificates at each upgrade.
- You can also [Rotate security credentials](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/rotate-credentials.md.txt) manually.

## Node security

GKE on AWS deploys your workloads onto node pools of AWS EC2
instances. The following sections explain how to use the node-level security
features in GKE on AWS.

### Ubuntu

GKE on AWS uses an optimized version of [Ubuntu](http://www.ubuntu.com) as the
operating system on which to run the Kubernetes control plane and nodes. Ubuntu
includes a rich set of modern [security features](https://wiki.ubuntu.com/Security/Features), and
GKE on AWS implements several security-enhancing features for
clusters, including:

- Optimized [package](https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64-root.manifest) set.
- Google Cloud-tailored [Linux kernel](https://git.launchpad.net/%7Ecanonical-kernel/ubuntu/+source/linux-gcp/+git/bionic/).
- Limited user accounts and disabled root login.

Additional security guides are available for Ubuntu, such as:

- [CIS Benchmark](https://www.cisecurity.org/benchmark/ubuntu_linux/)
- [DISA STIG](https://public.cyber.mil/stigs/)
- [FIPS 140-2](https://wiki.ubuntu.com/Security/Certification)

### Node upgrades

You should [upgrade your nodes](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/upgrading-user-cluster) on a
regular basis. From time to time, security issues in the container runtime,
Kubernetes itself, or the node operating system might require you to upgrade
your nodes more urgently. When you upgrade your user cluster, each node's
software is upgraded to their latest versions. Additionally, upgrading nodes
[rotates encryption credentials](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/rotate-credentials.md.txt).

## Securing your workloads

Kubernetes allows users to quickly provision, scale, and update container-based
workloads. This section describes tactics that you can use to limit side-effects
of running containers on cluster and the Google Cloud services.

### Limiting Pod container process privileges

Limiting the privileges of containerized processes is important for your
cluster's security. You can set security-related options with the
[Security Context](https://kubernetes.io/docs/tasks/configure-pod-container/security-context/) of Pods and containers. These settings let you
change the security settings of your processes such as:

- User and group running the process.
- Available Linux capabilities.
- Privilege escalation.

The default GKE on AWS node operating system, Ubuntu, applies the
default [Docker AppArmor security policies](https://docs.cloud.google.com/container-optimized-os/docs/how-to/secure-apparmor.md.txt#using_the_default_docker_apparmor_security_profile) to all containers started by
Kubernetes. You can view the profile's template on [GitHub](https://github.com/moby/moby/blob/master/profiles/apparmor/template.go). Among
other things, the profile denies the following abilities to containers:

- Writing to files directly in a process ID directory (`/proc/`).
- Writing to files that are not in `/proc/`.
- Writing to files in `/proc/sys` other than `/proc/sys/kernel/shm*`.
- Mounting file systems.

## What's next

- [Install a management service](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/installing-management.md.txt).
- [Use HashiCorp Vault on GKE on AWS](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/secrets-with-vault.md.txt).
- [Rotate your security credentials](https://docs.cloud.google.com/kubernetes-engine/multi-cloud/docs/aws/previous-generation/how-to/rotate-credentials.md.txt).