-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from 5GSEC/regis
Add SPIRE/SPIFFE Packages for Workload Identity
- Loading branch information
Showing
31 changed files
with
1,361 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: spire | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: spire-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# Source: spire-agent/templates/csi-serviceaccount.yaml | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: spiffe-csi-driver | ||
namespace: spire | ||
|
||
--- | ||
|
||
# Source: spire-agent/templates/spiffe-csi-driver.yaml | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: spiffe-csi-driver | ||
namespace: spire | ||
labels: | ||
app: spiffe-csi-driver | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: spiffe-csi-driver | ||
template: | ||
metadata: | ||
namespace: spire | ||
labels: | ||
app: spiffe-csi-driver | ||
spec: | ||
serviceAccountName: spiffe-csi-driver | ||
containers: | ||
# This is the container which runs the SPIFFE CSI driver. | ||
- name: spiffe-csi-driver | ||
image: ghcr.io/spiffe/spiffe-csi-driver:0.2.6 | ||
imagePullPolicy: IfNotPresent | ||
args: [ | ||
"-workload-api-socket-dir", "/spire-agent-socket", | ||
"-csi-socket-path", "/spiffe-csi/csi.sock", | ||
] | ||
env: | ||
# The CSI driver needs a unique node ID. The node name can be | ||
# used for this purpose. | ||
- name: MY_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
volumeMounts: | ||
# The volume containing the SPIRE agent socket. The SPIFFE CSI | ||
# driver will mount this directory into containers. | ||
- mountPath: /spire-agent-socket | ||
name: spire-agent-socket-dir | ||
readOnly: true | ||
# The volume that will contain the CSI driver socket shared | ||
# with the kubelet and the driver registrar. | ||
- mountPath: /spiffe-csi | ||
name: spiffe-csi-socket-dir | ||
# The volume containing mount points for containers. | ||
- mountPath: /var/lib/kubelet/pods | ||
mountPropagation: Bidirectional | ||
name: mountpoint-dir | ||
securityContext: | ||
readOnlyRootFilesystem: true | ||
capabilities: | ||
drop: | ||
- all | ||
privileged: true | ||
# This container runs the CSI Node Driver Registrar which takes care | ||
# of all the little details required to register a CSI driver with | ||
# the kubelet. | ||
- name: node-driver-registrar | ||
image: registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.6.0 | ||
imagePullPolicy: IfNotPresent | ||
args: [ | ||
"-csi-address", "/spiffe-csi/csi.sock", | ||
"-kubelet-registration-path", "/var/lib/kubelet/plugins/csi.spiffe.io/csi.sock", | ||
] | ||
volumeMounts: | ||
# The registrar needs access to the SPIFFE CSI driver socket | ||
- mountPath: /spiffe-csi | ||
name: spiffe-csi-socket-dir | ||
# The registrar needs access to the Kubelet plugin registration | ||
# directory | ||
- name: kubelet-plugin-registration-dir | ||
mountPath: /registration | ||
volumes: | ||
# This volume is used to share the Workload API socket between the CSI | ||
# driver and SPIRE agent. Note, an emptyDir volume could also be used | ||
# (if the CSI driver and SPIRE agent shared a pod), however, | ||
# this can lead to broken bind mounts in the workload | ||
# containers if the agent pod is restarted (since the emptyDir | ||
# directory on the node that was mounted into workload containers by | ||
# the CSI driver belongs to the old pod instance and is no longer | ||
# valid). | ||
- name: spire-agent-socket-dir | ||
hostPath: | ||
path: /run/spire/agent-sockets | ||
type: DirectoryOrCreate | ||
# This volume is where the socket for kubelet->driver communication lives | ||
- name: spiffe-csi-socket-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins/csi.spiffe.io | ||
type: DirectoryOrCreate | ||
# This volume is where the SPIFFE CSI driver mounts volumes | ||
- name: mountpoint-dir | ||
hostPath: | ||
path: /var/lib/kubelet/pods | ||
type: Directory | ||
# This volume is where the node-driver-registrar registers the plugin | ||
# with kubelet | ||
- name: kubelet-plugin-registration-dir | ||
hostPath: | ||
path: /var/lib/kubelet/plugins_registry | ||
type: Directory | ||
--- | ||
|
||
apiVersion: storage.k8s.io/v1 | ||
kind: CSIDriver | ||
metadata: | ||
name: "csi.spiffe.io" | ||
spec: | ||
# Only ephemeral, inline volumes are supported. There is no need for a | ||
# controller to provision and attach volumes. | ||
attachRequired: false | ||
|
||
# Request the pod information which the CSI driver uses to verify that an | ||
# ephemeral mount was requested. | ||
podInfoOnMount: true | ||
|
||
# Don't change ownership on the contents of the mount since the Workload API | ||
# Unix Domain Socket is typically open to all (i.e. 0777). | ||
fsGroupPolicy: None | ||
|
||
# Declare support for ephemeral volumes only. | ||
volumeLifecycleModes: | ||
- Ephemeral |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# ServiceAccount for the SPIRE agent | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: spire-agent | ||
namespace: spire | ||
|
||
--- | ||
|
||
# Required cluster role to allow spire-agent to query k8s API server | ||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: spire-agent-cluster-role | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods","nodes","nodes/proxy"] | ||
verbs: ["get"] | ||
|
||
--- | ||
|
||
# Binds above cluster role to spire-agent service account | ||
kind: ClusterRoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: spire-agent-cluster-role-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: spire-agent | ||
namespace: spire | ||
roleRef: | ||
kind: ClusterRole | ||
name: spire-agent-cluster-role | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: spire-agent | ||
namespace: spire | ||
labels: | ||
app: spire-agent | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: spire-agent | ||
updateStrategy: | ||
type: RollingUpdate | ||
template: | ||
metadata: | ||
namespace: spire | ||
labels: | ||
app: spire-agent | ||
spec: | ||
hostPID: true | ||
hostNetwork: true | ||
dnsPolicy: ClusterFirstWithHostNet | ||
serviceAccountName: spire-agent | ||
containers: | ||
- name: spire-agent | ||
image: ghcr.io/spiffe/spire-agent:1.8.0 | ||
imagePullPolicy: IfNotPresent | ||
args: ["-config", "/run/spire/config/agent.conf"] | ||
volumeMounts: | ||
- name: spire-config | ||
mountPath: /run/spire/config | ||
readOnly: true | ||
- name: spire-bundle | ||
mountPath: /run/spire/bundle | ||
readOnly: true | ||
- name: spire-token | ||
mountPath: /var/run/secrets/tokens | ||
- name: spire-agent-socket-dir | ||
mountPath: /run/spire/sockets | ||
volumes: | ||
- name: spire-config | ||
configMap: | ||
name: spire-agent | ||
- name: spire-bundle | ||
configMap: | ||
name: spire-bundle | ||
- name: spire-token | ||
projected: | ||
sources: | ||
- serviceAccountToken: | ||
path: spire-agent | ||
expirationSeconds: 7200 | ||
audience: spire-server | ||
# This volume is used to share the Workload API socket between the CSI | ||
# driver and SPIRE agent. Note, an emptyDir volume could also be used, | ||
# however, this can lead to broken bind mounts in the workload | ||
# containers if the agent pod is restarted (since the emptyDir | ||
# directory on the node that was mounted into workload containers by | ||
# the CSI driver belongs to the old pod instance and is no longer | ||
# valid). | ||
- name: spire-agent-socket-dir | ||
hostPath: | ||
path: /run/spire/agent-sockets | ||
type: DirectoryOrCreate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: pod-reader | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods", "nodes"] | ||
verbs: ["get"] |
25 changes: 25 additions & 0 deletions
25
nephio/optional/spire-restrictedSA/ClusterRoleBinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: spire-agent-tokenreview-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: spirekubeconfig | ||
namespace: spire | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: system:auth-delegator | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: spire-agent-pod-reader-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: spirekubeconfig | ||
namespace: spire | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: pod-reader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: restricted-SA | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: restricted-SA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: agent-sa-secret | ||
namespace: spire | ||
annotations: | ||
kubernetes.io/service-account.name: spirekubeconfig | ||
type: kubernetes.io/service-account-token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: spirekubeconfig | ||
namespace: spire |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: kpt.dev/v1 | ||
kind: Kptfile | ||
metadata: | ||
name: spire | ||
annotations: | ||
config.kubernetes.io/local-config: "true" | ||
info: | ||
description: sample description |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# spire | ||
|
||
## Description | ||
sample description | ||
|
||
## Usage | ||
|
||
### Fetch the package | ||
`kpt pkg get REPO_URI[.git]/PKG_PATH[@VERSION] spire` | ||
Details: https://kpt.dev/reference/cli/pkg/get/ | ||
|
||
### View package content | ||
`kpt pkg tree spire` | ||
Details: https://kpt.dev/reference/cli/pkg/tree/ | ||
|
||
### Apply the package | ||
``` | ||
kpt live init spire | ||
kpt live apply spire --reconcile-timeout=2m --output=table | ||
``` | ||
Details: https://kpt.dev/reference/cli/live/ |
Oops, something went wrong.