Skip to content

Add vitess/lite ubi8 images for mysql80, including for arm64#9830

Merged
deepthi merged 7 commits intovitessio:mainfrom
planetscale:jg_lite_arm64
Mar 29, 2022
Merged

Add vitess/lite ubi8 images for mysql80, including for arm64#9830
deepthi merged 7 commits intovitessio:mainfrom
planetscale:jg_lite_arm64

Conversation

@aquarapid
Copy link
Copy Markdown
Contributor

@aquarapid aquarapid commented Mar 4, 2022

Today, Vitess has no facility for building non-x86_64 vitess/lite images. This PR fixes that. To simplify matters, I used the Red Hat ubi8 images, which has good aarch64 support. I then added a vitess/lite image for both the ubi8/amd64(x86_64) and ubi8/arm64(aarch64) combos.

To build this on an Intel machine, you will need your local docker installation to support cross compiling for linux/arm64. The easiest way to achieve this is to use https://github.com/tonistiigi/binfmt , specifically by running something like:

$ docker run --privileged --rm tonistiigi/binfmt --install arm64

before doing your build.

You can confirm that your installation is capable of cross-compilation by doing something like:

$ docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS  PLATFORMS
default * docker                  
  default default         running linux/amd64, linux/386, linux/arm64

Note the linux/arm64 option.

If you just want to build the 2 new images, you can do that:

for amd64:

$ make docker_lite_ubi8.mysql80

for arm64:

$ make docker_lite_ubi8.arm64.mysql80

Future cross-build docker containers just need to include the arm64 string in the build target name (i.e. ubi8.arm64.mysql80 in this case) to trigger the cross-compilation.

Finally, the lite container for arm64/aarch64 excludes a few things that are not available on aarch64:

  • xtrabackup
  • Percona Toolkit
    xtrabackup is the big one here; so if you use these images to run your Vitess MySQL instances, you will have to either rely on the "builtin" (offline) backup; or you will have to supply your own xtrabackup binaries (in theory it is possible to build it on aarch64, but Percona does not test this or provide binaries, yet).

Signed-off-by: Jacques Grove <aquarapid@gmail.com>
containers, to match our other containers

Signed-off-by: Jacques Grove <aquarapid@gmail.com>
@aquarapid aquarapid added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Build/CI release notes labels Mar 4, 2022
Copy link
Copy Markdown
Collaborator

@vmg vmg left a comment

Choose a reason for hiding this comment

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

This looks good! How many Vitess contributors have M1 macs that could test this? It would be nice to have some confidence in the implementation besides the cross-compilation way.

@deepthi
Copy link
Copy Markdown
Collaborator

deepthi commented Mar 7, 2022

This looks good! How many Vitess contributors have M1 macs that could test this? It would be nice to have some confidence in the implementation besides the cross-compilation way.

On a M1 Mac running zsh

$ make docker_lite_ubi8.arm64.mysql80
Building vitess/lite:ubi8.arm64.mysql80
/bin/bash: -c: line 1: syntax error: unexpected end of file
make: *** [docker_lite_ubi8.arm64.mysql80] Error 2
$ make -n docker_lite_ubi8.arm64.mysql80
Building vitess/lite:ubi8.arm64.mysql80
# Fix permissions before copying files, to avoid AUFS bug other must have read/access permissions
chmod -R o=rx *;
if grep -q arm64 <<< vitess/lite:ubi8.arm64.mysql80; then
# arm64/aarch64 build, use docker cross build
docker buildx build --platform linux/arm64 -f docker/lite/Dockerfile.ubi8.arm64.mysql80 -t vitess/lite:ubi8.arm64.mysql80 --build-arg bootstrap_version=4 .;
else
docker build -f docker/lite/Dockerfile.ubi8.arm64.mysql80 -t vitess/lite:ubi8.arm64.mysql80 --build-arg bootstrap_version=4 .;
fi

@aquarapid
Copy link
Copy Markdown
Contributor Author

I don't have a Mac, so I cannot test any of this there.

@aquarapid
Copy link
Copy Markdown
Contributor Author

I cannot reproduce, even using zsh on Linux.

Signed-off-by: Jacques Grove <aquarapid@gmail.com>
blocks...

Signed-off-by: Jacques Grove <aquarapid@gmail.com>
@aquarapid aquarapid requested a review from mattlord as a code owner March 19, 2022 02:10
Signed-off-by: Jacques Grove <aquarapid@gmail.com>
Signed-off-by: Jacques Grove <aquarapid@gmail.com>
Signed-off-by: Jacques Grove <aquarapid@gmail.com>
Copy link
Copy Markdown
Member

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Thanks! I had a few questions but nothing that should block us. We can iterate from here.

Comment on lines +90 to +95
if [ -d /go/bin ]; then
# Probably in the bootstrap container
(cd go/cmd/vttablet && go run github.com/GeertJohan/go.rice/rice --verbose append --exec=/go/bin/${GOOS}_${GOARCH}/vttablet)
else
(cd go/cmd/vttablet && unset GOOS && unset GOARCH && go run github.com/GeertJohan/go.rice/rice --verbose append --exec=$${HOME}/go/bin/${GOOS}_${GOARCH}/vttablet)
fi
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious why we don't rely on ${GOPATH}/bin here? It is set inside the container, and should be set on any other system:

$ echo "GOBIN: ${GOPATH}/bin"                                                                                                                                                    
GOBIN: /Users/matt/go/bin
$ docker run -it vitess/bootstrap:mysql80 /bin/bash -c 'echo "GOBIN: ${GOPATH}/bin"'
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
GOBIN: /go/bin

Would there be any other reason to use a different command?

mkdir -p "$${PREFIX}/bin"
cp "$${VTROOT}/bin/"{mysqlctl,mysqlctld,vtorc,vtadmin,vtctld,vtctlclient,vtctldclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/"

# Will only work inside the docker bootstrap for now
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Worth printing this out to the console then too, IMO.

io.k8s.display-name="Vitess Lite image - MySQL Community Server 8.0" \
maintainer="cncf-vitess-maintainers@lists.cncf.io" \
vendor="CNCF" \
version="13.0.0" \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the wrong version for main. I'd just remove it as I don't see where we have that in the other images. Or if we really need it, something like:

$ grep versionName go/vt/servenv/version.go | awk '{print $4}' | tr -d '"'
14.0.0-SNAPSHOT

@mattlord
Copy link
Copy Markdown
Member

mattlord commented Mar 29, 2022

For anyone that's interested ...

Here's the details from my local tests on my m1 Mac laptop:
$ uname -a && sw_vers
Darwin pslord.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101 arm64
ProductName:	macOS
ProductVersion:	12.3
BuildVersion:	21E230


$ docker version
Client:
 Cloud integration: v1.0.22
 Version:           20.10.13
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 10 14:08:43 2022
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.6.1 (76265)
 Engine:
  Version:          20.10.13
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       906f57f
  Built:            Thu Mar 10 14:05:37 2022
  OS/Arch:          linux/arm64
  Experimental:     true
 containerd:
  Version:          1.5.10
  GitCommit:        2a1d4dbdb2a1030dc5b01e96fb110a9d9f150ecc
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0


$ docker buildx ls
NAME/NODE       DRIVER/ENDPOINT             STATUS   PLATFORMS
mybuilder       docker-container
  mybuilder0    unix:///var/run/docker.sock inactive
desktop-linux   docker
  desktop-linux desktop-linux               running  linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
default *       docker
  default       default                     running  linux/arm64, linux/amd64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6


$ make docker_lite_ubi8.arm64.mysql80
Building vitess/lite:ubi8.arm64.mysql80
Building docker using arm64 buildx
...
 => exporting to image                                                                                                                                                                                                                                                                                                                                                                    3.0s
 => => exporting layers                                                                                                                                                                                                                                                                                                                                                                   3.0s
 => => writing image sha256:e02f214af127fdd440085ce7654965684ce637b7dfb182f1537f7cc02da487c6                                                                                                                                                                                                                                                                                              0.0s
 => => naming to docker.io/vitess/lite:ubi8.arm64.mysql80


$ docker image inspect vitess/lite:ubi8.arm64.mysql80
[
    {
        "Id": "sha256:e02f214af127fdd440085ce7654965684ce637b7dfb182f1537f7cc02da487c6",
        "RepoTags": [
            "vitess/lite:ubi8.arm64.mysql80"
        ],
        "RepoDigests": [],
        "Parent": "",
        "Comment": "buildkit.dockerfile.v0",
        "Created": "2022-03-29T18:01:13.79921326Z",
        "Container": "",
        "ContainerConfig": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": null,
            "Cmd": null,
            "Image": "",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "DockerVersion": "",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "vitess",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/vt/src/vitess.io/vitess/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "container=oci",
                "VTROOT=/vt/src/vitess.io/vitess",
                "VTDATAROOT=/vt/vtdataroot",
                "MYSQL_FLAVOR=MySQL80"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "",
            "Volumes": {
                "/vt/vtdataroot": {}
            },
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "architecture": "arm64",
                "build-date": "2022-03-16T16:54:12.025385",
                "com.redhat.build-host": "arm-003.osbs.prod.upshift.rdu2.redhat.com",
                "com.redhat.component": "ubi8-container",
                "com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
                "description": "Vitess base container image, containing Vitess components along with MySQL Community Server 8.0",
                "distribution-scope": "public",
                "io.k8s.description": "Vitess base container image, containing Vitess components along with MySQL Community Server 8.0",
                "io.k8s.display-name": "Vitess Lite image - MySQL Community Server 8.0",
                "io.openshift.expose-services": "",
                "io.openshift.tags": "base rhel8",
                "maintainer": "cncf-vitess-maintainers@lists.cncf.io",
                "name": "Vitess Lite image - MySQL Community Server 8.0",
                "release": "1",
                "summary": "Vitess base container image, containing Vitess components along with MySQL Community Server 8.0",
                "url": "https://vitess.io",
                "vcs-ref": "3aadd00326f3dd6cfe65ee31017ab98915fddb56",
                "vcs-type": "git",
                "vendor": "CNCF",
                "version": "13.0.0"
            }
        },
        "Architecture": "arm64",
        "Os": "linux",
        "Size": 1392687409,
        "VirtualSize": 1392687409,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/jmuqdmuk06gddlh3rq5suen39/diff:/var/lib/docker/overlay2/nt63jf7636z6hd0okedkm44ip/diff:/var/lib/docker/overlay2/x5pqsiwn589h7g7x97hhftshk/diff:/var/lib/docker/overlay2/vnkrsnrjejne1o0iazd5on9da/diff:/var/lib/docker/overlay2/yuuxxuwhbbpgwrnklvcp50puc/diff:/var/lib/docker/overlay2/umvqsz49audhui79tsq13xd9b/diff:/var/lib/docker/overlay2/v1tsy7aqgffnmj5spzazx7zcn/diff:/var/lib/docker/overlay2/pzpsr1voroqqii4fo0o3gthyy/diff:/var/lib/docker/overlay2/5ea838b9e287b64c27dda523cfddea4bd5d322488475501046042cb1de8639a8/diff:/var/lib/docker/overlay2/7c78dfec4ae6bdb4e383e85be923cd05b1207a14583d328b7404b631372d03cf/diff",
                "MergedDir": "/var/lib/docker/overlay2/7okuwihep19c4lndijye41x0s/merged",
                "UpperDir": "/var/lib/docker/overlay2/7okuwihep19c4lndijye41x0s/diff",
                "WorkDir": "/var/lib/docker/overlay2/7okuwihep19c4lndijye41x0s/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:8ce5fefd85ad52a7787c3f1519d2326e05fb35f0de382229452f787f8c537346",
                "sha256:51c5c556ef659da2c901af1b5aec583d26f84592319f6e57d94f6a5a459bcb0e",
                "sha256:e31fb12f68ec0f4928eff6430387e8804f4de5aae276c52f33149116ab69c307",
                "sha256:fa7c707dc1a883870657ee2f67bf8cbf9eb7fc174ad4408730eba98433b2f3b3",
                "sha256:cf6a01547b0b61973020047daf94d6897493c7d39eed7b3907b336b5cd92cddf",
                "sha256:97944c4297620b268a054af176993857bb559af6717b98b3def565594650dfc3",
                "sha256:261502b4b617ef2e031f4bdc0912d9adabef22636f869bc064f97fd913e09cdf",
                "sha256:d1aaf0303bfa1774e37ff3d1584b1800d7e32033c1fc012b121de941d9330edc",
                "sha256:df62d62c8892395a632613e1d732634ddeee8edc43bfb591ca4011573e572518",
                "sha256:f7ec0042993dea04df5561b2fe83d98efce5364399a50abdf2cb025ac31cd7c5",
                "sha256:78fbe27bb01ca2bb3a16dd3bf106f931fe6d33bdaee269d0460f78f96b59a0eb"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]


$ docker run -it vitess/lite:ubi8.arm64.mysql80
bash-4.4$ uname -a
Linux 26d65c628a4b 5.10.104-linuxkit #1 SMP PREEMPT Wed Mar 9 19:01:25 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
bash-4.4$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.5 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.5 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/red_hat_enterprise_linux/8/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.5
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.5"
bash-4.4$ /vt/bin/vtgate -version
ERROR: logging before flag.Parse: E0329 18:38:50.510747      11 syslogger.go:149] can't connect to syslog
W0329 18:38:50.557858      11 flag.go:109] Use of single-dash long flags is deprecated and will be removed in the next version of Vitess. Please use --version instead
Version: 14.0.0-SNAPSHOT (Git revision 7f12ed9d49 branch 'jg_lite_arm64') built on Tue Mar 29 17:51:03 UTC 2022 by vitess@buildkitsandbox using go1.18 linux/arm64

@deepthi deepthi merged commit 5ff3acf into vitessio:main Mar 29, 2022
@deepthi deepthi deleted the jg_lite_arm64 branch March 29, 2022 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Build/CI Type: Enhancement Logical improvement (somewhere between a bug and feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants