Skip to content

Commit

Permalink
Remove PodSecurityPolicy from Terraform configs (#6874)
Browse files Browse the repository at this point in the history
Remove also ClusterRole and ClusterRoleBinding resources that were
used to enact the PodSecurityPolicy policies.

The current recommended Kubernetes version for these configs is 1.23
 * updated autoscaler image tag v.1.21.0 -> v.1.23.0
 * updated autoscaler permissions to the recommended set for this version

The recommended mechanism to replace PodSecurityPolicy is [Pod
Security Standards](https://v1-23.docs.kubernetes.io/docs/tasks/configure-pod-container/migrate-from-psp/).

 * removed SYS_RESOURCE from requested capability set for Haproxy
Deployment for compatibility with the PSS Baseline profile. Without
this change, the entire "default" namespace would have to run under
the Privileged profile, possibly compromising the security of the
validator nodes.
  • Loading branch information
sionescu authored and rustielin committed Mar 2, 2023
1 parent 079cc28 commit 5a7ca31
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 477 deletions.
13 changes: 9 additions & 4 deletions terraform/aptos-node-testnet/aws/addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,20 @@ data "aws_iam_policy_document" "cluster-autoscaler" {
}
}

# Recommended config https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/cloudprovider/aws/README.md
statement {
sid = "DescribeAutoscaling"
actions = [
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeAutoScalingGroups",
"ec2:DescribeLaunchTemplateVersions",
"autoscaling:DescribeAutoScalingInstances",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeScalingActivities",
"autoscaling:DescribeTags",
"autoscaling:DescribeLaunchConfigurations"
"ec2:DescribeInstanceTypes",
"ec2:DescribeLaunchTemplateVersions",
"ec2:DescribeImages",
"ec2:GetInstanceTypesFromInstanceRequirements",
"eks:DescribeNodegroup"
]
resources = ["*"]
}
Expand Down Expand Up @@ -150,7 +156,6 @@ resource "helm_release" "chaos-mesh" {
}
chaos-mesh = {
chaosDaemon = {
podSecurityPolicy = true
# tolerate pod assignment on nodes in the validator nodegroup
tolerations = [{
key = "aptos.org/nodepool"
Expand Down
1 change: 0 additions & 1 deletion terraform/aptos-node-testnet/gcp/addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ resource "helm_release" "chaos-mesh" {
jsonencode({
chaos-mesh = {
chaosDaemon = {
podSecurityPolicy = true
}
}
})
Expand Down
4 changes: 0 additions & 4 deletions terraform/helm/aptos-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ ServiceAccounts:
* `<RELEASE_NAME>-validator` - The validator service account
* `<RELEASE_NAME>-fullnode` - The fullnode service account

[optional] PodSecurityPolicy:
* `<RELEASE_NAME>` - The default PodSecurityPolicy for validators and fullnodes
* `<RELEASE_NAME>-haproxy` - The PodSecurityPolicy for HAProxy

## Common Operations

### Check Pod Status
Expand Down
1 change: 0 additions & 1 deletion terraform/helm/aptos-node/templates/haproxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ spec:
drop:
- ALL
add:
- SYS_RESOURCE
- SETUID
{{- with .nodeSelector }}
nodeSelector:
Expand Down
187 changes: 0 additions & 187 deletions terraform/helm/aptos-node/templates/securitypolicy.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions terraform/helm/aptos-node/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ serviceAccount:
# -- The name of the service account to use. If not set and create is true, a name is generated using the fullname template
name:

# -- LEGACY: create PodSecurityPolicy, which exists at the cluster-level
podSecurityPolicy: true

# -- Load test-data for starting a test network
loadTestGenesis: false

Expand Down
2 changes: 1 addition & 1 deletion terraform/helm/autoscaling/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ autoscaler:
scaleDownDelayAfterAdd: 5m
image:
repo: k8s.gcr.io/autoscaling/cluster-autoscaler
tag: v1.21.0
tag: v1.23.0
resources:
requests:
cpu: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,49 +41,3 @@ subjects:
namespace: {{ .Release.Namespace }}

---
# Grant some basic permissions to the dashboard and controller manager
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ include "chaos.fullname" . }}
spec:
privileged: false # Don't allow privileged pods!
# The rest fills in some required fields.
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
runAsUser:
rule: RunAsAny
fsGroup:
rule: RunAsAny
volumes:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "chaos.fullname" . }}-psp
rules:
- apiGroups: ["policy"]
resources: ["podsecuritypolicies"]
verbs: ["use"]
resourceNames:
- {{ include "chaos.fullname" . }}
---

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "chaos.fullname" . }}-psp
roleRef:
kind: ClusterRole
name: {{ include "chaos.fullname" . }}-psp
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: chaos-controller-manager
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: chaos-dashboard
File renamed without changes.
71 changes: 0 additions & 71 deletions terraform/helm/fullnode/templates/psp.yaml

This file was deleted.

1 change: 0 additions & 1 deletion terraform/helm/genesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Aptos blockchain automated genesis ceremony for testnets
| genesis.validator.larger_stake_amount | string | `"1000000000000000"` | Stake amount for each validator in this testnet. Defaults to 1M APTOS coins with 8 decimals |
| imageTag | string | `"testnet"` | Default image tag to use for all tools images |
| labels | string | `nil` | |
| podSecurityPolicy | bool | `true` | LEGACY: create PodSecurityPolicy, which exists at the cluster-level |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `nil` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |

Expand Down
Loading

0 comments on commit 5a7ca31

Please sign in to comment.