Mirantis Launches DevOpsCare for All Major Kubernetes Platforms

DevOpsCare, powered by Lens boosts developer productivity and job satisfaction by removing infrastructure concerns and freeing devs to focus on building great applications   CAMPBELL, Calif., December 2, 2021 — Mirantis, the open cloud company, today announced DevOpsCare, powered by Lens, a vendor-agnostic, fully-managed CI/CD (continuous integration/continuous deployment) product for any Kubernetes environment, offering developers higher … Continued
Quelle: Mirantis

Introducing DevOpsCare Powered by Lens

Today at Mirantis we are excited to announce the launch of our newest offering, DevOpsCare powered by Lens. While our previous products and offerings have been mainly focused on operators, we recognize the needs of the “Dev” half of “DevOps”, and DevOpsCare powered by Lens is designed specifically to address that challenge. DevOpsCare: The Challenge … Continued
Quelle: Mirantis

Using BigQuery with data sources in Google Cloud VMware Engine

This blog is intended for customers who have migrated on-premises data sources to Google Cloud VMware Engine and want to utilize data and analytics services provided by Google Cloud. One of the objectives of customers who choose Google Cloud is to leverage Google Cloud analytics with their datasets. If you are an IT decision maker or a data architect who wants to quickly use the power of your data with Google analytics, this blog describes approaches to access your data within BigQuery, where advanced analytics and machine learning on your datasets is possible. Why?Data consumption and analytics is at the forefront of technology. Customers today consume and manage large amounts of data and resource pools. These challenges create an opportunity for Google Cloud to assist in managing and understanding your existing databases without having the need to undergo costly re-architecting of your source material or data location. This blog presents approaches to access Google Cloud data and analytics services with your existing data without having to re-architect your databases. Once your data sources are in Google Cloud VMware Engine, Google’s highly available and fault tolerant infrastructure can be leveraged to enhance the performance of data pipelines. These solutions aim to reduce time to value extraction from your datasets with cloud native analytics available via BigQuery.  This solution of migrating via Google Cloud VMware Engine offers advantages to all parts of data operations. The database administrator (DBA) and virtual infrastructure/cloud admins can use familiar environments similar to on-premises on the cloud. The on-premises infrastructure team can enable the data scientist/AI/machine learning (ML) teams using familiar toolsets. These teams now have access to Google Cloud AI/ML/data analytics capabilities for their on-premises data.For example, if you want to uncover cross-sell opportunities within your products, the first step is to ensure that product usage and billing datasets across your products are connected for analytics. The DBA team will identify these datasets and the infrastructure team will enable access to these sources. The application team will then replicate this data to BigQuery and use approaches such as BigQuery ML recommendations to uncover cross-sell opportunities. Another example of a use case is forecasting usage growth for operations and growth planning. Once your sales data is replicated within BigQuery, approaches for advanced time-series forecasting become available with your datasets.What does this cover?We present approaches to replicate your relational datasets within BigQuery in a private and secure way utilizing either Google Cloud Data Fusion or Google Cloud Datastream. Datafusion is an ETL tool that supports various kinds of data pipelines. Datastream is a service for change-data-capture and replication. Using both these services, data is always within your projects in Google Cloud and internal IP is used to access data. We will focus on real-time replication, so that you can access your data continuously from operational data stores, such as SQL Server, MySQL, and Oracle within BigQuery. Moving data from your data sources to the cloud and maintaining data pipelines to your data warehouses via Extract Transform Load (ETL) is a time consuming activity. An alternate approach is ELT (Extract Load Transform). The ELT approach loads data into the target system (e.g., BigQuery) before transforming the data. The ELT process is frequently preferred over the traditional ETL process because it’s simpler to realize and loads the data faster.With your datasets now residing in the Google Cloud, data teams can utilize Cloud Data Fusion and Datastream over the high speed, low latency Google Cloud network to replicate or move data from your VMware infrastructure to various destinations in Google Cloud such as Google Cloud native storage buckets or BigQuery. For simplicity, we will assume that all services are consumed within the same project. We will also discuss some pricing implications when moving data from Google Cloud VMware Engine from on-premises or another virtual private cloud (VPC).Cloud Data Fusion: Cloud Data Fusion provides a visual point-and-click interface that enables code-free deployment of ETL/ELT data pipeline. Cloud Data Fusion also provides a replication accelerator that allows you to replicate your tables into BigQuery. Cloud Data Fusion internally sets up a tenant project with its own VPCs to manage Cloud Data Fusion resources. To access data sources within Google Cloud VMware Engine using Cloud Data Fusion, we use a reverse proxy on the main VPC. This is described in the image below.In this scenario, we have our data workloads running on the Google Cloud VMware Engine instance within the project. The Google Cloud VMware Engine environment is accessed via a project level VPC peered with Google Cloud VMware Engine. A Google Compute Engine instance on the project level VPC exposes reverse proxy to the Google Cloud VMware Engine database to services that are unable to access the Google Cloud VMware Engine instance directly. A Cloud Data Fusion instance is enabled with private IP access and network peering to the main VPC and is able to access the data via the reverse proxy instance. This process to set up internal IP access and network peering on Cloud Data Fusion is described in this documentation.Once this peering is complete, we use a Java Database Connectivity connector within Cloud Data Fusion to access our databases either for replication or for advanced ETL operations. To enable change data capture, we need to enable the database within Google Cloud VMware Engine to track and capture the changes to the databases. This entire process setup and replication are described in the documentation for MySQL and for SQL Server. Google Cloud Datastream:Datastream is a serverless change data capture and replication service. You can access streaming, low-latency data from Oracle, and MySQL databases on Google Cloud VMware Engine. This approach offers more flexibility in managing data flow pipelines. This solution is currently in pre-general availability and is only available in select regions.This option also requires a reverse proxy configured within a Google Compute Engine instance. This reverse proxy is used to access data sources within Google Cloud VMware Engine. This option is described in this documentation.The complete setup to use Datastream can be found in this how-to guide. To enable replication, we need a stream configured on Datastream, this stream accesses data from the database and pipes the data to the cloud storage sink. Datastream accesses data using  a reverse proxy which needs to be exposed on the customer’s VPC. To pipe the data to BigQuery, we use a pre-configured Datastream to BigQuery template within Dataflow.How to get started?First step is to migrate workloads to Google Cloud VMware Engine. Your cloud admin/architect will typically drive this. If not already identified during the migration phase, the next step is to identify databases residing on virtual machines hosted within Google Cloud VMware Engine, and recreate existing reports using BigQuery. In most organizations there will be multiple personas involved with this process. For example, a data architect might be the best source for info on data sources, a solutions architect will have insights on the cost/performance implications, and the infrastructure inputs will be needed for network interfaces. The steps below outline one possible approach to enable this motion.  Identify datasets residing on virtual machines migrated to Google Cloud VMware Engine that are used for reports. Select the right pipeline (Datastream vs. Data Fusion) based on the database type and the pipeline requirements (price/performance trade offs and ease of use).Based on the data pipeline, select the appropriate region. There are no data egress charges within the same region. Setup the reverse proxy to the Google Cloud VMware Engine dataset. Setup the replication service with performance parameters based on the replication performance needed.Enable analytics and visualization based on the business requirements on the dataset.Conclusion:The Google Cloud VMware Engine service is a fast and easy way to enable data and analytics visualization using your existing data sets. You can now leverage your existing infrastructure operational posture on VMware to enable cloud analytics without having to undergo time consuming re-architecting of your databases. These approaches enable you to leverage the performance benefits of dedicated hardware on Google Cloud, connecting with the world’s most advanced data capabilities.  Acknowledgements:The authors would like to thank Manoj Sharma and Sai Gopalan regarding their inputs on this blog.Related ArticleMonitoring made simple for Google Cloud VMware Engine and Google Cloud operations suiteLearn how we simplified monitoring for Google Cloud VMware Engine and Google Cloud operations suite.Read Article
Quelle: Google Cloud Platform

Unlocking opportunities with data transformation

One of the biggest challenges data executives have today is turning the immense amount of information that their organization, customers and partners — or rather their whole ecosystem — are creating into a competitive advantage. In my role here at Google Cloud, I specialize in everything data — from analytics, to business intelligence, data science and AI. My team’s role is split into 3 main activities:Engagement with customers and partner community. About 70% of my time is spent with customers. And it’s where I’ve gathered all these insights that I’m going to share with you today.  Product strategy and execution. This time is for strategizing and planning around all our new Cloud launches and products.Go-To-Market globally. This is where we ask all the tough questions: How do we make it easier for our customers to onboard? And get the most out of our services? To transform and innovate? And then we solve for them.It’s safe to say data-driven transformation is my bread and butter. And I want it to be yours too. My aim is to help people think about data in a new way — not something to be afraid of, but something to leverage and grow with. There are still lots of problems to be solved in our industry. But data is helping us unlock a world of opportunities.What modern data architectures look like todayThere’s a treasure trove of new technologies that are transforming the way companies do business at incredible speeds. I think of companies like Paypal, which migrated over 20 petabytes of data to serve its 3,000+ users, and Verizon Media, which ingested 200 terabytes of data daily and stored 100 petabytes in BigQuery. Even traditional retailers like Crate & Barrel are making strides in the cloud, doubling their return-on-ad-spend (ROAS) while only increasing investment by 20%.But what do these companies all have in common? A modern approach to their data practices and platforms. And there are three attributes that I think all organizations should take into account: 1. Embrace the old with the new.  Every single one of the most important brands on earth has legacy systems. They’ve developed leadership over decades and these systems (before the cloud came along) got them there.2. Don’t discard what’s going to get you there (i.e multi-cloud). All modern architectures today are multi-cloud by default. According to Flexera, over 80% of businesses reported using a multi-cloud strategy this year and over 90%  have a hybrid  strategy in place.3. Data is no longer a stagnant asset. Organizations that win with data think about it as part of an ‘ecosystem’ of opportunity, where insights arise from emerging data — whether it be from interconnected data networks or the data from their partners. And this is a trend organizations should keep their eye on. A study from Gartner predicts that by 2023, organizations that promote data sharing will outperform their peers on most business value metrics.How to make the best hires for your data teamLeaders often say that their competitive advantage comes from their people, not just services or products. While most companies are now recognizing the importance of data and analytics, many still struggle to get the right people in place. The best way to look at how many data people to hire is to ask yourself, what percentage of my total employee base should they make up? I agree with Kirk Borne, Chief Scientist Officer at DataPrime Solutions, who says that your entire organization should be ‘data literate’. And when we say literate, we mean recognize, understand and talk data. One third of your company should be ‘data fluent’ — meaning able to analyze and present informed results with data. And finally, 10% of employees should be ‘data professionals’ that are paid to create value from data. That’s where all your chief scientists, data analysts, engineers and Business Intelligence specialists come into play.The ideal data team structure of course depends on the type and size of the company. Furniture and home e-commerce company Wayfair for instance has approximately 3,000 engineers and data scientists — close to 18% of its total workforce. Who should own the data? There are a lot of questions around who data leaders should work for and who should own that data. It’s  tough to answer because there are so many choices. Should it be the CTO? Or the CFO, whose initiatives are around cost reduction? Or the CPO, who may focus on product analytics only? When asking customers at scale, it’s typically under the CFO or CTO. And while that makes sense, I think there’s something else we should be asking: How should data be approached so that companies are enabled to innovate with it?A trend we’re hearing a lot more about is data mesh. This data ownership approach basically centralizes data and decentralizes analytics through ‘data neighborhoods.’ This allows business users and data scientists to access, analyze, and augment insights, but in a way that’s connected to the centralized strategy and abides by corporate rules and policies.Data neighborhoodsData: 2022 and beyondData analytics, data integration and data processing can be very complex, especially as we begin to modernize. So I’d like to leave you with a ‘gotcha’ moment — and that’s data sharing. You can’t expect to reap the benefits of data instantly. First you have to work with it, clean it up and analyze it. The real innovators are those looking at the wider picture — considering analytics solutions and sharing and combining datasets.My advice for people who want to get started? Forget the notion of new and existing use cases and focus on business value from day one. How are you going to measure that? And how are you sharing that with leaders that are supporting your initiative? Data is constantly growing and trends are always shifting. So we need to stay on our toes. Data-driven transformation gives businesses real-time insights and prepares you for the unpredictable. So looking forward to 2022, I’d say use data to plan for change and plan for the unexpected.A data cloud offers a comprehensive and proven approach to cloud — allowing you to increase agility, innovate faster, get value from your data and support business transformation. Google Cloud is uniquely positioned to help businesses get there. Learn how. 
Quelle: Google Cloud Platform

Anthos makes multi-cloud easier with new API, support for Azure

One of the main reasons organizations adopt Anthos is to simplify the management of Kubernetes-based applications across a variety of clouds. And now, with our latest release, we’ve made multi-cloud management even easier with the general availability of the Anthos Multi-Cloud API.In addition, in this latest release,Support for Anthos clusters1 running on Azure is also now generally availableWe’ve added integrated logging and monitoringWe’ve introduced Connect Gateway support for unified cluster access, with Terraform and Kubernetes Config Connector support coming soon! Let’s take a deeper look at what you can find in our latest Anthos release. Exploring the Multi-Cloud APIWith the latest release of Anthos, we’ve trimmed our installation footprint and streamlined our cluster management technology to allow you to use a single API for full lifecycle management of Anthos clusters running in AWS or Azure. Compare that to previous releases, which required you to install a management cluster in each cloud. Now, the Anthos Multi-Cloud API, the Google Cloud control plane does all the work! This release standardizes the gcloud CLI for deploying Anthos clusters in AWS, Azure, and GCP (with full Terraform support on the way). Clusters you create in other clouds appear in the Google Cloud Console, creating a centralized management view complete with cluster telemetry and logging. Now, creating a new Anthos cluster on Google Cloud, AWS or Azure is a simple gcloud command:Here’s the associated view from the Cloud Console:The Multi-Cloud API performs authentication with each cloud via service account or application registration, and allows clusters to be deployed on existing or newly created VPCs/Vnets. It supports multiple machine types in each cloud, with plans to support even more soon (AWS, Azure). As a reminder, Anthos clusters on Azure or AWS integrate with each respective cloud’s native KMS, storage facilities, and load balancing. Using Connect Gateway to connect to Anthos clusters in AWS and AzureConnect gateway allows you to interact with your Anthos clusters securely, and now it works with Anthos clusters running on AWS and Azure too. Cluster commands are routed through a GCP Service to your clusters over an encrypted connection, removing the need for end users to use a VPN. Putting together a multi-cloud strategyOperationalizing Google-managed Kubernetes clusters in all three major clouds is now much easier with the release of the Multi-Cloud API. The next step is to apply configuration governance and policy controls to the clusters which will create safe and secure deployment landing zones for your applications regardless of the environment.For one thing, you can now leverage Anthos Configuration Management (ACM), which automates policy and security at scale for Kubernetes clusters whether they are running on-premises, on GCP, and on other public clouds. ACM synchronizes your clusters to a git repository that contains your business specific configurations and policies. Developers can launch their applications by adding configuration files to the ACM repo or they can use their existing CD tooling. In either case, by using ACM, you can be sure security and governance is applied uniformly across your fleet of clusters.Meanwhile, Cloud Run for Anthos and Anthos Service Mesh offer tremendous value to organizations looking to optimize and secure Kubernetes-based workloads. Cloud Run for Anthos enables container-based application deployments that scale to zero with predictable costs in your own clusters while making use of existing CI/CD pipelines and security tooling. Anthos Service Mesh brings advanced application networking capabilities to your services and valuable inter-cluster communication telemetry, and is designed to work on Anthos clusters running on GKE, AWS and Azure. These Anthos capabilities are critical to businesses that manage microservice-based applications at scale; look for them to be released in the coming in the coming monthsGet started todayAnthos clusters are enterprise-grade Kubernetes clusters that are entirely supported by Google Cloud — and now running them in AWS and Azure is a seamless experience. To get started, check out our Install Anthos Clusters on AWS or Azure guide.1. An Anthos cluster refers to a Google-managed Kubernetes cluster that can run outside of Google Cloud.
Quelle: Google Cloud Platform

Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide

There are some important changes happening in the software industry. With Apple moving all of their machines to their custom ARM-based silicon and AWS offering the best performance-per-cost ratio with their Graviton2 instances, one can no longer expect that all software only needs to run on x86 processors. If you work with containers there is some good tooling available for building multi-platform images when your development teams are using different architectures or you want to deploy to a different architecture from the one that you develop on. In this post, I’ll show some patterns that you can use if you want to get the best performance out of such builds.

In order to build multi-platform container images, we will use the docker buildxcommand. Buildx is a Docker component that enables many powerful build features with a familiar Docker user experience. All builds executed via buildx run with Moby Buildkit builder engine. Buildx can also be used standalone or, for example, to run builds in a Kubernetes cluster. In the next version of Docker CLI, the docker buildcommand will also start to use Buildx by default.

By default, a build executed with Buildx will build an image for the architecture that matches your machine. This way, you get an image that runs on the same machine you are working on. In order to build for a different architecture, you can set the–platform flag, e.g. –platform=linux/arm64. To build for multiple platforms together, you can set multiple values with a comma separator.

# building an image for two platforms
docker buildx build –platform=linux/amd64,linux/arm64 .

In order to build multi-platform images, we also need to create a builder instance as building multi-platform images is currently only supported when using BuildKit with docker-container and kubernetes drivers. Setting a single target platform is allowed on all buildx drivers.

docker buildx create –use
# building an image for two platforms
docker buildx build –platform=linux/amd64,linux/arm64 .

When building a multi-platform image from a Dockerfile, effectively your Dockerfile gets built once for each platform. At the end of the build, all of these images are merged together into a single multi-platform image.

FROM alpine
RUN echo “Hello” > /hello

For example, in the case of a simple Dockerfile like this that is built for two architectures, BuildKit will pull two different versions of the Alpine image, one containing x86 binaries and another containing arm64 binaries, and then run their respective shell binary on each of them.

Different methods of building

Generally, the CPU of your machine can only run binaries for its native architecture. x86 CPU can’t run ARM binaries and vice versa. So when we are running the above example on an Intel machine, how can it run the shell binary for ARM? It does this by running the binary through a software emulator instead of doing so directly.

docker buildx ls shows what emulators are installed for each of the builders. If you don’t see them listed for your system you can install them with the tonistiigi/binfmt image.

Using an emulator this way is very easy. We don’t need to modify our Dockerfile at all and can build for multiple platforms automatically. But it doesn’t come without downsides. The binaries running this way need to constantly convert their instructions between architectures and therefore don’t run with native speed. Occasionally you might also find a case that triggers a bug in the emulation layer.

One way to avoid this overhead is to modify your Dockerfile so that the longest-running commands don’t run through an emulator. Instead, we can use a cross-compilation stage.

The difference between emulation and cross-compilation is that in the former, we emulate the full system of another architecture in software, while in cross-compilation we only use binaries built for our native architecture with a special configuration option that makes them generate new binaries for our target architecture. As the name says, this technique can not be used for all processes but mostly only when you are running a compiler. Luckily the two techniques can be combined. For example, your Dockerfile can use emulation to install packages from the package manager and use cross-compilation to build your source code.

Emulation vs. cross-compilation build with “ — platform=linux/amd64,linux/arm64″ as run on Intel/AMD machine. Blue contains x86 binaries, yellow ARM binaries.

When deciding whether to use emulation or cross-compilation, the most important thing to consider is if your process is using a lot of CPU processing power or not. Emulation is usually a fine approach for installing packages or if you need to create some files or run a one-off script. But if using cross-compilation can make your builds (possibly tens of) minutes faster, it is probably worth updating your Dockerfile. If you want to run tests as part of the build then cross-compilation can not achieve that. For the best performance in that case, another option is to use a remote build cluster with multiple machines with different architectures.

Preparing Dockerfile

In order to add cross-compilation to our Dockerfile, we will use multi-stage builds. The most common pattern to use in multi-stage builds is to define a build stage(s) where we prepare our build artifacts and a runtime stage that we export as a final image. We will use the same method here with an extra condition that we want our build stage to always run binaries for our native architecture and our runtime stage to contain binaries for the target architecture.

When we start a build stage with a command like FROM debian it instructs the builder to pull the Debian image that matches the value that was set with –platform flag during your build. What we want to do instead is to make sure this Debian image is always native to our current machine. When we are on an x86 system we could instead use a command like FROM –platform=linux/amd64 debian. Now, no matter what platform was set during the build, this stage will always be based on amd64. Except what happens now if we switch to an ARM machine like the new Apple Macs? Do we now need to change all our Dockerfiles? The answer is no, and instead of writing a constant platform value into our Dockerfile we should use a variable instead, FROM –platform=$BUILDPLATFORM debian.

BUILDPLATFORM is part of a set of automatically defined (global scope) build arguments that you can use. It will always match the platform or your current system and the builder will fill in the correct value for us.

Here is a complete list of such variables:

BUILDPLATFORM — matches the current machine. (e.g. linux/amd64)

BUILDOS — os component of BUILDPLATFORM, e.g. linux

BUILDARCH — e.g. amd64, arm64, riscv64

BUILDVARIANT — used to set ARM variant, e.g. v7

TARGETPLATFORM — The value set with –platform flag on build

TARGETOS – OS component from –platform, e.g. linux

TARGETARCH – Architecture from –platform, e.g. arm64

TARGETVARIANT

Now in our build stage, we can pull in our source code, install the compiler package we want to use, etc. These commands should be identical to the ones you are already using in your single-platform or emulation-based Dockerfile.

The only additional change that needs to be done now is that when you are calling your compiler process you need to pass it a parameter that configures it to return artifacts for your actual target architecture. Remember that now that our build stage always contains binaries for the host’s native architecture, the compiler can’t determine the target’s architecture automatically from the environment anymore.

In order to pass the target architecture, we can use the same automatically defined build arguments shown before, this time with TARGET* prefix. As we are using these build arguments inside the stage, they need to be in the local scope and declared with a ARG command before being used.

FROM –platform=$BUILDPLATFORM alpine AS build
# RUN <install build dependecies/compiler>
# COPY <source> .
ARG TARGETPLATFORM
RUN compile –target=$TARGETPLATFORM -o /out/mybinary

The only thing left to do now is to create a runtime stage that we will export as a result of our build. For this stage, we will not use –platform in the FROM definition. We could write FROM –platform=$TARGETPLATFORM but that is the default value for all builds stages anyway so using a flag is redundant.

FROM alpine
# RUN <install runtime dependencies installed via emulation>
COPY –from=build /out/mybinary /bin

To confirm, let’s look at what happens if the above Dockerfile is built for two platforms with docker buildx build –platform=linux/amd64,linux/arm64 . invoked on ARM64-based systems like new Apple M1 machines.

First, the builder will pull down the Alpine image for ARM64, install the build dependencies and copy over the source. Note that these steps execute only once, even though we are building for two different platforms. BuildKit is smart enough to understand that both of these platforms depend on the same compiler and source code and automatically deduplicates the steps.

Now two separate instances of containers running the compiler process will be invoked, with a different value passed to the –target flag.

For the export stage, BuildKit now pulls down both ARM64 and x86 versions of the Alpine image. If any runtime packages were used then the x86 versions are installed with the help of the emulation layer. All these steps already ran in parallel to the build stage as they did not share dependencies. As the last step, the binary created by the respective compiler process is copied to the stage.

Sample Dockerfile commands as run on Apple M1 machine. Blue contains x86 binaries, yellow ARM.

Both of the runtime stages are then converted into an OCI image and BuildKit will prepare an OCI Image Index structure(also called a manifest list)that contains both of these images.

Go example

For a functional example, let’s look at an example project written in the Go programming language.

A typical multi-stage Dockerfile building a simple Go application would look something like:

FROM golang:1.17-alpine AS build
WORKDIR /src
COPY . .
RUN go build -o /out/myapp .

FROM alpine
COPY –from=build /out/myapp /bin

Using cross-compilation in Go is very easy. The only thing you need to do is pass the target architecture with environment variables. go build understands GOOS , GOARCH environment variables. There is also GOARM for specifying the ARM version for the 32bit systems.

The GOOS and GOARCH values are the same format as the TARGETOS and TARGETARCH values which we saw earlier that BuildKit makes available inside the Dockerfile.

When we apply all the steps we learned before: fixing the build stage to build platform, defining ARG TARGET* variables, and passing cross-compilation parameters to the compiler we will have:

FROM –platform=$BUILDPLATFORM golang:1.17-alpine AS build
WORKDIR /src
COPY . .
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/myapp .

FROM alpine
COPY –from=build /out/myapp /bin

As you see we only needed to do three small modifications and our Dockerfile is much more powerful. Note that there are no downsides to these changes, the Dockerfile is still portable and works in all architectures. Just now when we build for a non-native architecture our builds are much faster.

Let’s look at some additional optimizations you might want to consider as well.

When Go applications depend on other Go modules they usually do it by either including the sources of the dependencies inside a vendor directory or if their project does not include such a directory then the Go compiler will pull the dependencies listed in the go.mod file while the go build command is running.

In the latter case, it means that (although our own source code was copied only one time) because thego build process was invoked twice for our multi-platform build, these dependencies would also be pulled twice. It’s better to avoid that by telling Go to download these dependencies before we branch our build stage with the ARG TARGETARCH command.

FROM –platform=$BUILDPLATFORM golang:1.17-alpine AS build
WORKDIR /src
COPY go.mod go.sum .
RUN go mod download
COPY . .
ARG TARGETOS TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/myapp .FROM alpine
COPY –from=build /out/myapp /bin

Now when two go build processes run they already have access to the pre-pulled dependencies. We also copied only thego.mod and go.sum files before downloading the packages so that when our regular source code changes we don’t invalidate cache for the module downloads.

For completeness, let’s also include cache mounts inside our Dockerfile. RUN –mount options allow exposing new mountpoints to the command that may be used for accessing your source code, build secrets, temporary and cache directories. Cache mounts create persistent directories where you can write your application-specific cache files that reappear the next time you invoke the builder again. This results in big performance gains when you are doing incremental builds after making changes to your source code.

In Go, the directories that you want to turn into cache mounts are /root/.cache/go-build and /go/pkg . The first is the default location of the Go build cache and the second is where go mod downloads modules. This assumes your user is root and GOPATH is /go .

RUN –mount=type=cache,target=/root/.cache/go-build
–mount=type=cache,target=/go/pkg
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/myapp .

You can also use a type=bind mount (default type) to mount in your source code. This helps to avoid the overhead of actually copying the files with COPY . In cross-compiling in Dockerfile, it is sometimes especially important if you don’t want to copy your source before defining ARG TARGETPLATFORM as changes in the source code would invalidate the cache for your target-specific dependencies. Note that type=bind mounts are mounted read-only by default. If the commands you are running need to write files to your source code, you might still want to use COPY or set therw option for the mount.

This leads to our complete, fully-optimized cross-compiling Go Dockerfile:

FROM –platform=$BUILDPLATFORM golang:1.17-alpine AS build
WORKDIR /src
ARG TARGETOS TARGETARCH
RUN –mount=target=.
–mount=type=cache,target=/root/.cache/go-build
–mount=type=cache,target=/go/pkg
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/myapp .

FROM alpine
COPY –from=build /out/myapp /bin

As an example, I measured how much time it takes to build the Docker CLI binary with the multi-stage Dockerfile we started with and then the one with the optimizations applied. As you can see, the difference is quite drastic.

https://github.com/docker/cli build time with test Dockerfiles (seconds, lower is better)

For the initial build only for our native architecture, the difference is minimal — only a small change from not needing to run the COPY instruction. But when we build an image both for ARM and x86 CPUs the difference is huge. For our new Dockerfile, doubling architectures increases build time only by 70% (because some parts of the builds were shared), while when the second architecture builds with QEMU emulation, our build time is almost seven times longer.

With the additional help from the cache mounts that we added, our incremental rebuilds with a Go source code changes are reaching a ridiculous 100x speed improvement territory compared to the old Dockerfile.
The post Faster Multi-Platform Builds: Dockerfile Cross-Compilation Guide appeared first on Docker Blog.
Quelle: https://blog.docker.com/feed/

Amazon Athena unterstützt jetzt die neue Lake Formation mit fein abgestufter Sicherheit und zuverlässigen Tabellenfunktionen

Amazon Athena-Benutzer können jetzt AWS Lake Formation verwenden, um fein abgestufte Zugriffsberechtigungen zu konfigurieren und Daten aus ACID-kompatiblen Tabellen auszulesen. Amazon Athena erleichtert die Analyse von Daten in Amazon S3-basierten Data Lakes. Die Sicherstellung, dass Nutzer nur auf Daten zugreifen können, die für sie freigegeben sind, und dass ihre Abfragen angesichts von Änderungen an den zugrunde liegenden Daten zuverlässig sind, kann eine komplexe Aufgabe sein.
Quelle: aws.amazon.com