Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scaffolding to stand up Trillian on k8s. #2754

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

vaikas
Copy link
Contributor

@vaikas vaikas commented Jun 7, 2022

Signed-off-by: Ville Aikas vaikas@chainguard.dev

Fixes #2672

Here's the pieces for scaffolding and for createtree. I split them into two different directories because then applying just the scaffolding bits is easier and more well contained. Apply all the everythings :)

Createtree is a standalone job that makes creating trees in the k8s cluster easier and then because the entry is stuffed into configmap, it's easy to 'depend' on that for other jobs that may need it. For example, we have also a setup for spinning up a CTLog on top of this in sigstore, but wasn't sure if that might be of interest. I noticed that in README.md one of the steps after spinning up Trillian is to install CTLog on top of it.

https://github.com/sigstore/scaffolding/tree/main/config/ctlog

After creating the README-SCAFFOLDING.md in the examples dir, I noticed the PR template sez to add it to docs/ but I'm not sure if this belongs there since it's related to running tests, etc.

Lastly, the added kind test in github workflows only checks the configmap that the treeID was created, might be good to add some examples to test the grpc api as well, but figured that could be a followup if that makes sense.

Checklist

@vaikas vaikas requested a review from a team as a code owner June 7, 2022 11:45
@vaikas vaikas requested a review from jiggoha June 7, 2022 11:45
@roger2hk
Copy link
Contributor

roger2hk commented Jun 7, 2022

/gcbrun

@vaikas
Copy link
Contributor Author

vaikas commented Jun 7, 2022

@roger2hk Thanks for the gcbrun.

trillian-pr-tests are failing but I can't see why, can somebody share what the problem is so I can try to fix it :)
https://github.com/google/trillian/pull/2754/checks?check_run_id=6774522500

@pav-kv
Copy link
Contributor

pav-kv commented Jun 7, 2022

running golangci-lint
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\""
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\"\n\n"

go.mod Outdated Show resolved Hide resolved
Copy link
Contributor

@pav-kv pav-kv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups, I did not intend to approve this PR just yet, still needs review. Please ignore it.

@mhutchinson mhutchinson self-assigned this Jun 22, 2022
@mhutchinson mhutchinson self-requested a review June 22, 2022 14:01
Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few nits from a first glance. Do you want to rebase this onto HEAD, and meanwhile this week I'll try setting up an environment so I can follow the instructions here to really make sure it makes sense to me :-)

(apologies for late response, life has been busy the last 3 weeks!)

cmd/createtree-k8s/main.go Outdated Show resolved Hide resolved
cmd/createtree-k8s/main.go Outdated Show resolved Hide resolved
@vaikas
Copy link
Contributor Author

vaikas commented Jun 27, 2022

Thanks for the comments! Sorry for tardy response, was out on PTO, will pick this back up this week! @mhutchinson totes understood about life sometimes getting very busy :)

@AlCutter
Copy link
Member

/gcbrun

```
3. Then create a tree in the Trillian:
```shell
ko apply -BRf ./examples/deployment/kubernetes/createtree
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to add an issue (assigned to me) and TODO here to swap this over to use a pre-built image so that ko isn't needed.

@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson mhutchinson reopened this Jun 29, 2022
@mhutchinson
Copy link
Contributor

/gcbrun

Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, modulo a few comments.

Comment on lines +38 to +43
- name: Setup mirror
uses: chainguard-dev/actions/setup-mirror@main
with:
mirror: mirror.gcr.io
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this mirror?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases esp. in test environments this can reduce flakiness by not hitting rate limits on pulling containers. So by default we set this up before having to add it later :)

@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

This is failing running the lint checks:

Already have image (with digest): gcr.io/trillian-opensource-ci/trillian_testbase
running gofmt
running goimports
running golangci-lint
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\""
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\"\n\n"

@mhutchinson
Copy link
Contributor

golangci/golangci-lint#1920 may be relevant. Holler if you can't work this out and I'll take a deeper look.

@vaikas vaikas changed the title WIP: Add scaffolding to stand up Trillian on k8s. Add scaffolding to stand up Trillian on k8s. Jul 30, 2022
@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

This is still causing some problem with the linter. Fortunately it can be reproduced locally:

golangci-lint version
golangci-lint has version v1.47.3 built from (unknown, mod sum: "h1:ri7A2DgtFpxgqcMSsU3qIT0IBm/SCdYgXlvmJx4szUU=") on (unknown)

golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package v1: could not load export data: no export data for "k8s.io/client-go/applyconfigurations/meta/v1"
ERRO Running error: 1 error occurred:
	* can't run linter goanalysis_metalinter: buildir: failed to load package v1: could not load export data: no export data for "k8s.io/client-go/applyconfigurations/meta/v1"

@mhutchinson
Copy link
Contributor

mhutchinson commented Aug 3, 2022

I think this is because client-go is min version go1.18: https://github.com/kubernetes/client-go/blob/master/go.mod

golangci/golangci-lint#1920 (comment)

edit: but then again we're using v0.23.8, which is go1.16: https://github.com/kubernetes/client-go/blob/v0.23.8/go.mod

@mhutchinson
Copy link
Contributor

Hah, I've just spent ages messing about with looking into the linters and go versions. The answer appears to be as simple as running go build to find the root cause:

go build ./...
# k8s.io/client-go/applyconfigurations/meta/v1
../../go/pkg/mod/k8s.io/client-go@v0.23.8/applyconfigurations/meta/v1/unstructured.go:64:38: cannot use doc (variable of type *"github.com/googleapis/gnostic/openapiv2".Document) as type *"github.com/google/gnostic/openapiv2".Document in argument to proto.NewOpenAPIData

@mhutchinson
Copy link
Contributor

Root cause is probably kubernetes/client-go#1084. @vaikas can I leave this with you?

@vaikas
Copy link
Contributor Author

vaikas commented Aug 3, 2022

Thank you so much @mhutchinson for digging into this. I'll keep looking at it, oh what joy! 🤣

@vaikas
Copy link
Contributor Author

vaikas commented Aug 3, 2022

Ok, added a replace to go.mod and now things are building:

vaikas@villes-mbp trillian % go mod tidy -go=1.17 -compat=1.17
vaikas@villes-mbp trillian % git status
On branch k8s-createtree
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   go.mod
	modified:   go.sum
no changes added to commit (use "git add" and/or "git commit -a")
vaikas@villes-mbp trillian % go build ./...
vaikas@villes-mbp trillian %

Let's try this now :)

@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

Error is

Already have image (with digest): gcr.io/trillian-opensource-ci/trillian_testbase
running gofmt
running goimports
running golangci-lint
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\""
level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package version: could not load export data: no export data for \"sigs.k8s.io/release-utils/version\"\n\n"

Looks like a similar issue to the last one but with a different module. Oddly though, I can't reproduce this one locally with go build or golangci-lint. Will have a quick poke at this, but due to RL considerations I may need to leave this for @AlCutter to take over next week.

@JAORMX
Copy link
Collaborator

JAORMX commented Dec 13, 2022

@vaikas if you want to revisit this PR, the cloudbuild results are now viewable so it would be easier to debug.

@vaikas
Copy link
Contributor Author

vaikas commented Dec 15, 2022 via email

@mhutchinson
Copy link
Contributor

I'm back! Getting this PR in would be a great accomplishment for my return if you're up for it @vaikas :-)

@vaikas
Copy link
Contributor Author

vaikas commented Jan 9, 2023 via email

@vaikas
Copy link
Contributor Author

vaikas commented Feb 8, 2023

@mhutchinson would you mind hitting the magic test button (/gcbrun) for me please? :)

@roger2hk
Copy link
Contributor

roger2hk commented Feb 8, 2023

/gcbrun

matrix:
k8s-version:
- v1.22.x
- v1.23.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to add newer kube versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, oh dear :) Yes, done.

@roger2hk
Copy link
Contributor

roger2hk commented Feb 9, 2023

/gcbrun

Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
@roger2hk
Copy link
Contributor

/gcbrun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Would there be any interest in more k8s "native" tooling for integration testing?
7 participants