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

feat: introduce use of kapp-ctrl/packaging #87

Merged
merged 31 commits into from
Sep 22, 2021
Merged

feat: introduce use of kapp-ctrl/packaging #87

merged 31 commits into from
Sep 22, 2021

Conversation

cirocosta
Copy link
Contributor

@cirocosta cirocosta commented Sep 9, 2021

the commits tell most of the story, but here's the tl;dr on this pr:

  1. adds a packaging directory where we place templates and extra yaml objects
    (overlays & kapp configurations) that allow us to ship Cartographer as a
    carvel Package

  2. refactors ./hack/ci/e2e.sh and other ci related scripts which were not just
    meant to be run in CI to be more friendly with running locally, leaving to
    ci just those that assume a CI environment (like, install-binaries).

    • testing e2e locally now is a bit easier if you want to set up the
      envrionment once and then
  3. refactors the relase github actions workflow to be simply an automation on
    top of what we could do locally, i.e., removes any assumptions of being run
    from a CI environment.

at the end, we have a release directory (gitignored) like so:

./release/
├── CHANGELOG.md
├── bundle.tar
└── package
    ├── package-install.yaml
    ├── package-metadata.yaml
    └── package.yaml

with release notes such as

# Change Set

904ee8b Merge pull request #117 from vmware-tanzu/80-remove-comment
5eda41c Remove comment that now has a story associated
65ee7e5 Merge pull request #113 from vmware-tanzu/5-emit-results
<... manually redacted some here on github so it's not too big..>

# Installation

See https://github.com/vmware-tanzu/cartographer#installation.


# Checksums

```
bf3f222c57f3d2939a37c438f9002dbee6620ad28a415e535b50fe6b43a14c97  ./package/package-metadata.yaml
8dd3734081c38e699c73c7bb6706324b3c8cdda1f6bc1cc9c7a0a70895575b58  ./package/package-install.yaml
c04c0ae4eb9e5bff279ec7c5f837c8c3540db776c7f72dc233d1c47d0daa975d  ./package/package.yaml
0a0a4e34dd472ade52ee5e9f41c17c300ace92aef3cc8df5209871c8c45ec883  ./bundle.tar
```

i'm not sure how useful cartographer.yaml there is now that we're just bundling though ... might actually get rid of it and going solely for bundle / from source for those that want to try it out using ko by themselves ..


todo:

  • update the installation guide to guide through the use of bundle.tar

@cirocosta cirocosta marked this pull request as draft September 9, 2021 13:15
hack/dist.sh Outdated Show resolved Hide resolved
@cirocosta
Copy link
Contributor Author

at this point, just missing updating the commit message with the latest details

@cirocosta cirocosta force-pushed the packaging branch 2 times, most recently from 936242f to c7613f7 Compare September 17, 2021 13:04
@cirocosta cirocosta marked this pull request as ready for review September 17, 2021 13:16
@cirocosta
Copy link
Contributor Author

cirocosta commented Sep 17, 2021

todo:

  • account for ytt updates
    • inventoring of ytt deps (open source licensing .. etc)
    • update release.sh

@cirocosta cirocosta marked this pull request as draft September 17, 2021 15:56
@cirocosta cirocosta marked this pull request as ready for review September 17, 2021 16:10
@cirocosta cirocosta marked this pull request as draft September 20, 2021 14:12
@cirocosta
Copy link
Contributor Author

marking as draft once again to account for the installation based on the tarball

@cirocosta cirocosta marked this pull request as ready for review September 21, 2021 13:17
Ciro S. Costa added 23 commits September 22, 2021 15:45
we used to have the generation of release notes (i.e., what'd become the
body of the GitHub release) generated in a way that was suited only for
CI - this commit switches to an approach where we need not to rely on
anything CI specific as it can figure out the tag it's currently in via
plain use of `git` commands, even though the versions to use for the
notes generation _can_ be manually specified.

example: generate release notes for the assets under `./release`
(default) in a diff between the current tag and the previous tag
(default), writing them to `./release/CHANGELOG.md` (default)

	./hack/release-notes.sh

example: generates release notes for assets under `/foo` in a diff
between tag v0.0.4 and v0.0.1, writing the result to `/bar`

	ASSETS_DIR=/foo \
	DESTINATION=/bar \
	CURRENT_VERSION=v0.0.4 \
	PREVIOUS_VERSION=v0.0.1 \
		./hack/release-notes.sh

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
this script allows us to publish a github release, be on CI or not. note
that this does not generate any of the files related to the release - it
assumes that the files are already there, and so it just makes use of
github's cli[1] to submitting the release through its api. see
`hack/release.sh` and `hack/release-notes.sh` for release assets
generaiton.

example: use the current tag as the release version (default), the
`release/` directory as the place where `yaml` files to be released can
be found (default), and `release/CHANGELOG.md` as the release notes
body (default):

	./hack/github-release.sh

see `readonly` vars in the script for customization.

[1]: https://github.com/cli/cli

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
this commit brings back the functionality that we had for the previous
`hack/e2e.sh` script, but:

- broken down into separate commands
- by default, making use of an authenticated registry rather than not
- removing all resource reservations from our dependencies
- leveraging secretgen[1] for passing registry credential secrets to all
  namespaces
- using `kapp-ctrl/Package*` as the way of installing cartographer

with this setup we end up then replicating the setups of the real-world
much more closely, letting us be aware of the tweaks necessary for
working with private registries.

by having the funcionality of e2e.sh broken down into different
commands, it also becomes easier to bring a cluster locally and iterate
on an example, of install _just_ a subset of the dependencies you want.

for instance:

	1. bring up a local cluster with a registry and base
	dependencies we'd expect to be there
	(kapp-ctrl,cert-manager,secretgen):

		./hack/setup.sh cluster

	2. install cartographer using local code, pushing that to the
	local registry

		./hack/setup.sh cartographer

	3. setup the extra dependencies our examples use (like kpack,
	knative, etc)

		./hack/setup.sh example-dependencies

	4. run the example end to end

		./hack/setup.sh example

[1]: https://github.com/vmware-tanzu/carvel-secretgen-controller

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
with the introduction of `hack/setup.sh`, where everything is local by
default, there's no need for the `local-dev` scripts anymore.

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
with the aim at reducing the set of "installation sprawl", removing
these targets and focusing on the single installation location
(hack/setup.sh) we can instead just always use the commands from there.

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
- make use of `install-binaries` to install the binary dependencies
- move to `setup.sh` as the mechanism for bringing the cluster etc up

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
- to make sure that we're really confident about what we shipped, run it
through the same e2e tests that we run for commits/prs but with the
release candidate that we generate before finializing the release

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
as the stamper is now capable of stamping objects out making use of
`ytt`, we need to make it available inside the final container image.

leveraging `kodata`, we introduce an extra layer that includes the
binary as we want:

```
...
 drwxrwxrwx         0:0        0 B  ├── tmp
 drwxr-xr-x         0:0     1.6 MB  ├─⊕ usr
 dr-xr-xr-x         0:0      13 MB  └── var
 drwxr-xr-x         0:0        0 B      ├── backups
					...
 dr-xr-xr-x         0:0      13 MB      ├── run
 dr-xr-xr-x         0:0      13 MB      │   └── ko
 -r-xr-xr-x         0:0        5 B      │       ├── .gitignore
 -r-xr-xr-x         0:0      13 MB      │       └── ytt-linux-amd64	(!)
 drwxr-xr-x         0:0        0 B      ├── spool
 drwxrwxrwx         0:0        0 B      └── tmp
```

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
given that release generation is now done throguh `./hack/release.sh`
(either used directly or through `hack/setup.sh`), there's no need to
have that under Makefile anymore

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
it's great that we can point at specific versions, but _nothing_
prevents those versions from being updated.

with checksum verification we ensure that we're really getting what we
expect (sure sure, the paranoid in me would want to pgp verify those
from authors we trust ... but what we have here is certainly good
enough).

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
kubebuilder didn't follow the same pattern of having all of the binaries
landing on /usr/local/bin, which by default is open to our non-root
user on ubuntu.

by switching kubebuilder bins to that direcory, we have to let envtest
know that that's where it can find those binaries (apparently, it
doesn't search $PATH by default).

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
this way we can make sure that

1. we're getting what we expect
2. if we bump the version, we certainly include the right version

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
given that we don't yet have a public image registry that we can push
the bundle to, by generating a bundle tarball that goes to `/release` we
can not only preserve the ability for one to still install cartographer,
but also incentivize people to always relocate[^1]

[^1]: sure, once OSS, it's certainly useful to also have the 0-attrition
`kubectl apply -f <release_url>`

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
given that we're now not pushing to dockerhub anymore (as we're still
private) and we will be publishing the tarball of the whole bundle, we
can make the release workflow _much_ closer

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
we were referring to a version from feb 11 2021, no reason to not use a
newer one

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
this way we can more easily check out which versions we're installing by
referring to that set of variables at the very beginning of the file.

here I also made `example-dependencies` be more explicit about all the
dependencies it's installing so that just by looking at `main` one can
tell more precisely what goes on with each command.

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
given that we don't have the ability to just push our container images
to dockerhub anymore, we have to adapt the flow to be "github"-friendly
(aiming at OSS) while still preserving the properties of playing well
with carvel-packaging, which is usually aimed at a more enterprise-ready
workflow that involves relocation.

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
- previously, a release version would default to `0.0.0-dev` regardless
of wheteher we were under a tag or not.

- previously, the changeset computation would not produce the correct
results if we were working out of a release-candidate (it should diff
all the way down to the last non-rc).

Signed-off-by: Ciro S. Costa <ciroscosta@vmware.com>
@cirocosta
Copy link
Contributor Author

cirocosta commented Sep 22, 2021

force-pushed to resolve a conflict after rebasing w/ main

@cirocosta cirocosta merged commit 272f32b into main Sep 22, 2021
@cirocosta cirocosta deleted the packaging branch September 22, 2021 16:12
uses: actions/setup-go@v2
with:
go-version: '~1.17.1'
with: {go-version: '~1.17.1'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we switch to caret version matching? Go has committed to 1.x being compatible. go-version: '^1.17.1' ought to keep us on the latest minor and patch version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sgtm!

Comment on lines +20 to +27
readonly KO_VERSION=0.8.1
readonly KO_CHECKSUM=9f004fa1c2b55ac765ec0c287ad0311a517a86299b7a633bc542f2fbbb3a4ea4
readonly KUBERNETES_VERSION=1.19.2
readonly KUBERNETES_CHECKSUM=fb13a93a800389029b06fcc74ab6a3b969ff74178252709a040e4756251739d2
readonly KUTTL_VERSION=0.11.1
readonly KUTTL_CHECKSUM=0fb13f8fbb6109803a06847a8ad3fae4fedc8cd159e2b0fd6c1a1d8737191e5f
readonly GH_VERSION=2.0.0
readonly GH_CHECKSUM=20c2d1b1915a0ff154df453576d9e97aab709ad4b236ce8313435b8b96d31e5c
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these be passed in and defaulted? I foresee pain if we have to repro a build from a particular commit and a dependency version got pulled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sgtm!

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

Successfully merging this pull request may close these issues.

4 participants