Skip to content

Commit 0b56a52

Browse files
committed
Breaking down PR tektoncd#4759 originally proposed by @pxp928 to address TEP-0089 according @lumjjb suggestions. Plan for breaking down PR is PR 1.1: api PR 1.2: entrypointer (+cmd line + test/entrypointer) Entrypoint takes results and signs the results (termination message). PR 1.3: reconciler + pod + cmd/controller + integration tests Controller will verify the signed result. This commit corresponds to 1.3 above.
1 parent 963aa40 commit 0b56a52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2830
-141
lines changed

cmd/imagedigestexporter/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"context"
2021
"encoding/json"
2122
"flag"
2223

24+
"github.com/tektoncd/pipeline/pkg/spire"
25+
"github.com/tektoncd/pipeline/pkg/spire/config"
2326
"github.com/tektoncd/pipeline/pkg/termination"
2427
"knative.dev/pkg/logging"
2528

@@ -31,9 +34,12 @@ import (
3134
var (
3235
images = flag.String("images", "", "List of images resources built by task in json format")
3336
terminationMessagePath = flag.String("terminationMessagePath", "/tekton/termination", "Location of file containing termination message")
37+
enableSpire = flag.Bool("enable_spire", false, "If specified by configmap, this enables spire signing and verification")
38+
socketPath = flag.String("spire_socket_path", "unix:///spiffe-workload-api/spire-agent.sock", "Experimental: The SPIRE agent socket for SPIFFE workload API.")
3439
)
3540

36-
/* The input of this go program will be a JSON string with all the output PipelineResources of type
41+
/*
42+
The input of this go program will be a JSON string with all the output PipelineResources of type
3743
Image, which will include the path to where the index.json file will be located. The program will
3844
read the related index.json file(s) and log another JSON string including the name of the image resource
3945
and the digests.
@@ -76,6 +82,21 @@ func main() {
7682

7783
}
7884

85+
if enableSpire != nil && *enableSpire && socketPath != nil && *socketPath != "" {
86+
ctx := context.Background()
87+
spireConfig := config.SpireConfig{
88+
SocketPath: *socketPath,
89+
}
90+
91+
spireWorkloadAPI := spire.NewEntrypointerAPIClient(&spireConfig)
92+
signed, err := spireWorkloadAPI.Sign(ctx, output)
93+
if err != nil {
94+
logger.Fatal(err)
95+
}
96+
97+
output = append(output, signed...)
98+
}
99+
79100
if err := termination.WriteMessage(*terminationMessagePath, output); err != nil {
80101
logger.Fatalf("Unexpected error writing message %s to %s", *terminationMessagePath, err)
81102
}

config/config-feature-flags.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,8 @@ data:
9797
# Acceptable values are "v1beta1" and "v1alpha1".
9898
# The default is "v1alpha1".
9999
custom-task-version: "v1alpha1"
100+
# Setting this flag will determine how Tekton pipelines will handle non-falsifiable provenance.
101+
# If set to "spire", then SPIRE will be used to ensure non-falsifiable provenance.
102+
# If set to "none", then Tekton will not have non-falsifiable provenance.
103+
# This is an experimental feature and thus should still be considered an alpha feature.
104+
enforce-nonfalsifiablity: "none"

config/config-spire.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2022 The Tekton Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: v1
16+
kind: ConfigMap
17+
metadata:
18+
name: config-spire
19+
namespace: tekton-pipelines
20+
labels:
21+
app.kubernetes.io/instance: default
22+
app.kubernetes.io/part-of: tekton-pipelines
23+
data:
24+
_example: |
25+
################################
26+
# #
27+
# EXAMPLE CONFIGURATION #
28+
# #
29+
################################
30+
# This block is not actually functional configuration,
31+
# but serves to illustrate the available configuration
32+
# options and document them in a way that is accessible
33+
# to users that `kubectl edit` this config map.
34+
#
35+
# These sample configuration options may be copied out of
36+
# this example block and unindented to be in the data block
37+
# to actually change the configuration.
38+
#
39+
# spire-trust-domain specifies the SPIRE trust domain to use.
40+
# spire-trust-domain: "example.org"
41+
#
42+
# spire-socket-path specifies the SPIRE agent socket for SPIFFE workload API.
43+
# spire-socket-path: "unix:///spiffe-workload-api/spire-agent.sock"
44+
#
45+
# spire-server-addr specifies the SPIRE server address for workload/node registration.
46+
# spire-server-addr: "spire-server.spire.svc.cluster.local:8081"
47+
#
48+
# spire-node-alias-prefix specifies the SPIRE node alias prefix to use.
49+
# spire-node-alias-prefix: "/tekton-node/"

config/controller.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ spec:
117117
value: feature-flags
118118
- name: CONFIG_LEADERELECTION_NAME
119119
value: config-leader-election
120+
- name: CONFIG_SPIRE
121+
value: config-spire
120122
- name: CONFIG_TRUSTED_RESOURCES_NAME
121123
value: config-trusted-resources
122124
- name: SSL_CERT_FILE

0 commit comments

Comments
 (0)