Skip to content

Commit fe2e29d

Browse files
committed
Support downstream entries/spiffeIds (closes #43)
Signed-off-by: Keegan Witt <[email protected]>
1 parent 44d1494 commit fe2e29d

File tree

12 files changed

+29
-0
lines changed

12 files changed

+29
-0
lines changed

api/v1alpha1/clusterspiffeid_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type ClusterSPIFFEIDSpec struct {
6767
// administrative APIs. Extra care should be taken to only apply this
6868
// SPIFFE ID to admin workloads.
6969
Admin bool `json:"admin,omitempty"`
70+
71+
// Downstream indicates that the entry describes a downstream SPIRE server.
72+
Downstream bool `json:"downstream,omitempty"`
7073
}
7174

7275
// ClusterSPIFFEIDStatus defines the observed state of ClusterSPIFFEID

api/v1alpha1/clusterspiffeid_webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type ParsedClusterSPIFFEIDSpec struct {
8989
DNSNameTemplates []*template.Template
9090
WorkloadSelectorTemplates []*template.Template
9191
Admin bool
92+
Downstream bool
9293
}
9394

9495
// ParseClusterSPIFFEIDSpec parses and validates the fields in the ClusterSPIFFEIDSpec

config/crd/bases/spire.spiffe.io_clusterspiffeids.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ spec:
4848
items:
4949
type: string
5050
type: array
51+
downstream:
52+
description: Downstream indicates that the entry describes a downstream SPIRE server.
53+
type: boolean
5154
federatesWith:
5255
description: FederatesWith is a list of trust domain names that workloads
5356
that obtain this SPIFFE ID will federate with.

demo/config/cluster1/crd/spire.spiffe.io_clusterspiffeids.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ spec:
4848
items:
4949
type: string
5050
type: array
51+
downstream:
52+
description: Downstream indicates that the entry describes a downstream SPIRE server.
53+
type: boolean
5154
federatesWith:
5255
description: FederatesWith is a list of trust domain names that workloads
5356
that obtain this SPIFFE ID will federate with.

demo/config/cluster2/crd/spire.spiffe.io_clusterspiffeids.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ spec:
4848
items:
4949
type: string
5050
type: array
51+
downstream:
52+
description: Downstream indicates that the entry describes a downstream SPIRE server.
53+
type: boolean
5154
federatesWith:
5255
description: FederatesWith is a list of trust domain names that workloads
5356
that obtain this SPIFFE ID will federate with.

docs/clusterspiffeid-crd.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The definition can be found [here](../api/v1alpha1/clusterspiffeid_types.go).
2424
| `ttl` | OPTIONAL | Duration value indicating an upper bound on the time-to-live for SVIDs issued to target workload |
2525
| `federatesWith` | OPTIONAL | One or more trust domain names that target workloads federate with |
2626
| `admin` | OPTIONAL | Indicates whether the target workload is an admin workload (i.e. can access SPIRE administrative APIs) |
27+
| `downstream` | OPTIONAL | Indicates that the entry describes a downstream SPIRE server. |
2728

2829
## ClusterSPIFFEIDStatus
2930

pkg/spireapi/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type Entry struct {
4040
TTL time.Duration
4141
FederatesWith []spiffeid.TrustDomain
4242
Admin bool
43+
Downstream bool
4344
DnsNames []string
4445
}
4546

pkg/spireapi/types_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var (
3030
TTL: time.Minute,
3131
FederatesWith: []spiffeid.TrustDomain{spiffeid.RequireTrustDomainFromString("domain2.test")},
3232
Admin: true,
33+
Downstream: true,
3334
DnsNames: []string{"dnsname"},
3435
}
3536

@@ -47,6 +48,7 @@ var (
4748
Ttl: 60,
4849
FederatesWith: []string{"domain2.test"},
4950
Admin: true,
51+
Downstream: true,
5052
DnsNames: []string{"dnsname"},
5153
}
5254
)

pkg/spireentry/entries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func renderPodEntry(spec *spirev1alpha1.ParsedClusterSPIFFEIDSpec, node *corev1.
8080
FederatesWith: spec.FederatesWith,
8181
DnsNames: dnsNames,
8282
Admin: spec.Admin,
83+
Downstream: spec.Downstream,
8384
}, nil
8485
}
8586

pkg/spireentry/logging.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const (
3737
federatesWithKey = "federatesWith"
3838
dnsNamesKey = "dnsNames"
3939
adminKey = "admin"
40+
downstreamKey = "downstream"
4041
)
4142

4243
func objectName(o metav1.Object) string {
@@ -55,6 +56,7 @@ func entryLogFields(entry spireapi.Entry) []interface{} {
5556
federatesWithKey, stringFromTrustDomains(entry.FederatesWith),
5657
dnsNamesKey, stringList(entry.DnsNames),
5758
adminKey, entry.Admin,
59+
downstreamKey, entry.Downstream,
5860
}
5961
}
6062

0 commit comments

Comments
 (0)