Skip to content

Commit 3d27a9a

Browse files
authored
Merge pull request #28 from miyunari/bumo_to_v1.0.1
Bump model-validation-cli to v1.0.1 - Use the offical released image `ghcr.io/sigstore/model-transparency-cli:v1.0.1`. - Update signing step in github action. - Update controller.
2 parents 8007526 + cccfce7 commit 3d27a9a

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

.github/workflows/sign-model.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
env:
3131
OIDC_TOKEN: ${{ env.OIDC_TOKEN }}
3232
run: |
33-
docker run --rm -v $(pwd)/testdata/tensorflow_saved_model:/tensorflow_saved_model:z -w /tensorflow_saved_model ghcr.io/miyunari/model-transparency-cli:latest sign --sig_out=/tensorflow_saved_model/model.sig --model_path=/tensorflow_saved_model sigstore --identity-token "$OIDC_TOKEN"
33+
docker run --rm -v $(pwd)/testdata/tensorflow_saved_model:/tensorflow_saved_model:z -w /tensorflow_saved_model ghcr.io/miyunari/model-transparency-cli:latest sign sigstore --signature="/tensorflow_saved_model/model.sig" --identity_token "$OIDC_TOKEN" /tensorflow_saved_model
3434
3535
- name: Create tar.gz of the signed model
3636
run: |

manifests/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ spec:
1919
serviceAccountName: model-validation-controller-sa
2020
containers:
2121
- name: model-validation-controller
22-
image: ghcr.io/miyunari/model-validation-controller:latest
22+
image: ghcr.io/miyunari/model-validation-controller:v1.0.1
2323
ports:
2424
- containerPort: 8080
2525
volumeMounts:

manifests/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
apiVersion: kustomize.config.k8s.io/v1beta1
33
kind: Kustomization
44

5+
namespace: model-validation-controller
6+
57
resources:
8+
- namespace.yaml
69
- crd.yaml
710
- clusterrole.yaml
811
- service_account.yaml

manifests/namespace.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
apiVersion: v1
3+
kind: Namespace
4+
metadata:
5+
name: model-validation-controller

pod_webhook.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
// NewPodInterceptorWebhook creates a new pod mutating webhook to be registered
2020
func NewPodInterceptorWebhook(c client.Client, decoder admission.Decoder) webhook.AdmissionHandler {
2121
return &podInterceptor{
22-
client: c,
22+
client: c,
2323
decoder: decoder,
2424
}
2525
}
@@ -72,23 +72,22 @@ func (p *podInterceptor) Handle(ctx context.Context, req admission.Request) admi
7272
}
7373
}
7474

75-
args := []string{"verify",
76-
fmt.Sprintf("--model_path=%s", rhmv.Spec.Model.Path),
77-
fmt.Sprintf("--sig_path=%s", rhmv.Spec.Model.SignaturePath),
78-
}
79-
args = append(args, validationConfigToArgs(logger, rhmv.Spec.Config)...)
75+
args := []string{"verify"}
76+
args = append(args, validationConfigToArgs(logger, rhmv.Spec.Config, rhmv.Spec.Model.SignaturePath)...)
77+
args = append(args, rhmv.Spec.Model.Path)
8078

8179
pp := pod.DeepCopy()
8280
vm := []corev1.VolumeMount{}
8381
for _, c := range pod.Spec.Containers {
8482
vm = append(vm, c.VolumeMounts...)
8583
}
8684
pp.Spec.InitContainers = append(pp.Spec.InitContainers, corev1.Container{
87-
Name: modelValidationInitContainerName,
85+
Name: modelValidationInitContainerName,
8886
ImagePullPolicy: corev1.PullAlways,
89-
Image: "ghcr.io/miyunari/model-transparency-cli:latest", // TODO: get image from operator config.
90-
Command: args,
91-
VolumeMounts: vm,
87+
Image: "ghcr.io/sigstore/model-transparency-cli:v1.0.1", // TODO: get image from operator config.
88+
Command: []string{"/usr/local/bin/model_signing"},
89+
Args: args,
90+
VolumeMounts: vm,
9291
})
9392
marshaledPod, err := json.Marshal(pp)
9493
if err != nil {
@@ -98,23 +97,25 @@ func (p *podInterceptor) Handle(ctx context.Context, req admission.Request) admi
9897
return admission.PatchResponseFromRaw(req.Object.Raw, marshaledPod)
9998
}
10099

101-
func validationConfigToArgs(logger logr.Logger, cfg v1alpha1.ValidationConfig) []string {
100+
func validationConfigToArgs(logger logr.Logger, cfg v1alpha1.ValidationConfig, signaturePath string) []string {
102101
logger.Info("construct args")
103102
res := []string{}
104103
if cfg.SigstoreConfig != nil {
105104
logger.Info("found sigstore config")
106105
res = append(res,
107106
"sigstore",
107+
fmt.Sprintf("--signature=%s", signaturePath),
108108
"--identity", cfg.SigstoreConfig.CertificateIdentity,
109-
"--identity-provider", cfg.SigstoreConfig.CertificateOidcIssuer,
109+
"--identity_provider", cfg.SigstoreConfig.CertificateOidcIssuer,
110110
)
111111
return res
112112
}
113113

114114
if cfg.PrivateKeyConfig != nil {
115115
logger.Info("found private-key config")
116116
res = append(res,
117-
"private-key",
117+
"key",
118+
fmt.Sprintf("--signature=%s", signaturePath),
118119
"--public_key", cfg.PrivateKeyConfig.KeyPath,
119120
)
120121
return res
@@ -123,8 +124,9 @@ func validationConfigToArgs(logger logr.Logger, cfg v1alpha1.ValidationConfig) [
123124
if cfg.PkiConfig != nil {
124125
logger.Info("found pki config")
125126
res = append(res,
126-
"pki",
127-
"--root_certs", cfg.PkiConfig.CertificateAuthority,
127+
"certificate",
128+
fmt.Sprintf("--signature=%s", signaturePath),
129+
"--certificate_chain", cfg.PkiConfig.CertificateAuthority,
128130
)
129131
return res
130132
}

0 commit comments

Comments
 (0)