Anthillo /blog
← All posts

Floci - GCP in Your Home

Paweł Lewandowski

DevOps Engineer ·

The cloud is convenient, but we don’t always want to set up an entire GCP environment just to test a piece of an application, see how a service works, or simply experiment a little.

Sure, Google offers free tiers and starter credits, but we still need to create a project, configure access, and sometimes set up billing. Then there’s the need to make sure we haven’t left anything running after our tests that might start generating costs.

So what if we could run a little piece of Google Cloud locally, preferably in Docker, and forget about all the rest?

That’s where Floci GCP comes in — a Google Cloud service emulator that lets us run local equivalents of those services without using the actual cloud.

I decided to take a closer look. In this article, we’ll cover the basics, see what Floci can do, explore its limitations, and run a simple application in an emulated Cloud Run environment. Along the way, we’ll find out whether it’s actually worth our time.

What is Floci?

Floci is an open-source project aimed at emulating cloud provider services. Alongside Google Cloud, emulators for AWS, Azure, and OCI are also being developed.

We’re specifically interested in floci-gcp, the Google Cloud implementation.

The idea is fairly simple. Instead of sending requests to Google’s APIs, we point them at a locally running emulator. It receives and processes those requests, then returns responses that aim to behave as closely as possible to real GCP services.

Importantly, we can use standard Google Cloud API request formats and, for some services, native tools such as gcloud and the official client libraries. Usually, it’s a matter of redirecting the relevant endpoints to the emulator, although the exact configuration depends on the service.

Things get much more interesting with Cloud Run and Google Kubernetes Engine (GKE). Here, Floci doesn’t just return API responses — it can actually start application containers and, in the case of GKE, use a local cluster based on k3s.

This means we can test not only API calls but also selected application deployment and runtime scenarios without relying on Google’s infrastructure.

Of course, that doesn’t mean we’re running Google’s entire infrastructure on our own machines. Floci emulates selected APIs and service behaviors, and the level of compatibility depends on the specific functionality.

The project is released under the MIT license, so we can use it for free, including commercially.

What can we actually run?

The list of supported services is pretty extensive. It includes, among others:

ServiceWhat we can use it for
Cloud RunRunning containerized applications
GKEA local Kubernetes environment based on k3s
Cloud SQLPostgreSQL and MySQL databases
Compute EngineEmulating selected instance and disk operations
Cloud StorageStoring and retrieving files
Pub/SubAsynchronous communication between applications
BigQueryData operations and queries
FirestoreDocument database
Secret ManagerStoring secrets
IAMSelected permission management operations

And that’s only a subset of the available services.

One important thing to keep in mind: a supported service does not necessarily mean a fully implemented service.

For example, Floci might support creating and reading certain resources without implementing every mechanism that sits behind them in real GCP.

That’s why, before using the emulator in a larger project, it’s worth checking the documentation to make sure the operations we need are actually supported.

How does it work under the hood?

Floci GCP is built using Quarkus and GraalVM Native Image. In practice, that means we’re not running a traditional JVM application but a native executable.

This has a few advantages, most notably fast startup times and relatively low memory usage.

By default, the emulator listens on port 4588, exposing the APIs of its individual services through that port.

Interestingly, not all services work the same way.

With Cloud Storage or Pub/Sub, requests are handled directly by the emulator. We don’t need any additional containers or separate servers.

Cloud SQL works differently. Floci can start an actual PostgreSQL or MySQL container and expose it as the equivalent of a Google Cloud service.

A similar approach applies to Cloud Run, where application containers really are started, and to GKE, which uses k3s.

This distinction matters because it affects both what the emulator can do and how much hardware it needs.

Floci itself can be very lightweight, but once we start running databases or Kubernetes through it, resource consumption will depend on what we’ve actually deployed.

All right, let’s run something

If Floci is supposed to emulate Google Cloud, let’s test it with an example that resembles a normal infrastructure workflow. We’ll deploy a Cloud Run service using Terraform, start Nginx, and check whether the application actually works.

Why Terraform instead of gcloud run deploy? Normally, either approach makes sense, but here we run into an emulator limitation. gcloud run deploy uses the Cloud Run API v1, which Floci does not support. We verified this in practice: gcloud sent requests to /apis/serving.knative.dev/v1/..., while Floci responded correctly to Cloud Run Admin API v2 endpoints. Simply redirecting the API address isn’t enough to work around this.

Terraform, on the other hand, supports the google_cloud_run_v2_service resource through the official Google provider. That lets us deploy in much the same way we would in a real GCP project, except our requests go to Floci instead of Google.

Starting Floci

We’ll need Docker and Terraform installed. The emulator must have access to the Docker daemon because, in this example, it will actually start the application container.

docker run -d --name floci-gcp -p 127.0.0.1:4588:4588 -v /var/run/docker.sock:/var/run/docker.sock floci/floci-gcp:latest

Let’s check whether it started:

curl http://localhost:4588/health

Mounting /var/run/docker.sock gives the emulator extensive privileges on the host. That’s convenient in a local lab, but on a shared server it should be treated as a significant security risk.

Preparing the Terraform configuration

Create a working directory and a main.tf file inside it:

terraform {
  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 7.0"
    }
  }
}

provider "google" {
  project = "floci-local"
  region  = "europe-west1"

  user_project_override        = false
  cloud_run_v2_custom_endpoint = "http://localhost:4588/v2/"
}

resource "google_cloud_run_v2_service" "demo" {
  name                = "demo-web"
  location            = "europe-west1"
  deletion_protection = false
  ingress             = "INGRESS_TRAFFIC_ALL"

  template {
    containers {
      image = "nginx:alpine"

      ports {
        container_port = 80
      }

      resources {
        limits = {
          cpu    = "1"
          memory = "512Mi"
        }
      }
    }
  }
}

output "service_url" {
  value = google_cloud_run_v2_service.demo.uri
}

The service definition looks like what we’d use in a normal Terraform project. The difference is the cloud_run_v2_custom_endpoint parameter, which redirects the provider’s requests to our local emulator. We’ve also set deletion_protection = false so we can clean up the environment later without any trouble.

We’re not using a custom REST client or any special provider built for Floci.

Deployment

First, pull the application image:

docker pull nginx:alpine

For the local emulator, we’ll set a dummy token. This is not real Google Cloud authentication:

export GOOGLE_OAUTH_ACCESS_TOKEN=fake-token

Now we go through the standard Terraform workflow:

terraform init
terraform plan
terraform apply

init downloads the official Google provider, plan shows the proposed changes, and apply creates the Cloud Run resource in the emulator. At this point, Floci should start the Nginx container.

Checking what was created

Terraform should return the URL of the deployed service. We can also retrieve it separately:

terraform output -raw service_url

Then send a request to the application:

curl -i "$(terraform output -raw service_url)"

If the deployment succeeded and the URL is reachable from our host, we should get an HTTP 200 response and the default Nginx page.

We can also inspect the containers:

docker ps

This is where we can see the difference between simply emulating an API and running Cloud Run through Floci. Alongside the emulator container, there should also be a container running the actual application.

Updating and deleting the service

In a real project, we usually don’t stop after the first deployment. We can change the resource limits in main.tf, run terraform plan and terraform apply again, and then check the service’s state.

Finally, we clean up the environment with the standard command:

terraform destroy

That takes us through the entire resource lifecycle: declaration, deployment, verification, optional updates, and deletion.

Of course, this isn’t a full-fledged Cloud Run environment. Floci doesn’t reproduce all of Google’s mechanisms, particularly autoscaling or scale-to-zero. Even so, it lets us practice part of a real Infrastructure as Code workflow locally.

What about resource usage?

This is where Floci looks interesting, at least on paper.

According to the project’s authors, the native emulator starts in around 24 ms and uses approximately 13 MB of RAM when idle. In practice, we should expect usage closer to 65 MB of RAM, which seems like a small price to pay for a locally running test environment.

Of course, actual resource usage depends on what we do with the emulator.

If we stick to Cloud Storage, Pub/Sub, and a few simple operations, the requirements shouldn’t be particularly high.

But add Cloud SQL with PostgreSQL, a few Cloud Run applications, or a local GKE environment, and the picture changes.

Importantly, the emulator supports different ways of storing state, so we can choose between a temporary environment and a configuration that persists data to disk.

That can be useful in automated testing, for example, when we want to start with a clean environment every time.

The authors’ claims look promising, but it’s worth checking actual resource consumption on our own hardware, especially with more complex setups.

What are the benefits of using Floci?

First and foremost, we can test GCP services without using GCP.

It sounds obvious, but in many cases it’s genuinely convenient.

We don’t need to create separate test projects, configure billing, or keep an eye on resources accidentally left running.

There are several other benefits too.

Local environment. Our application can communicate with emulated services without connecting to the real cloud. We just need to configure the appropriate endpoints.

Test automation. We can run Floci in CI/CD pipelines, provision resources, execute integration tests, and tear down the entire environment afterward.

Terraform and OpenTofu. We can use Infrastructure as Code to provision selected resources instead of creating everything manually.

Repeatability. With the right configuration, we can recreate the same kind of test environment as many times as we need.

Offline support. Once the required images and dependencies have been downloaded, basic scenarios don’t need an internet connection.

And, of course, there’s the cost. Floci itself is free, and the resources we run locally won’t generate Google Cloud bills.

What’s the catch?

As usual, there’s no such thing as a free lunch.

The biggest limitation is the lack of full compatibility with the real Google Cloud.

Floci reproduces selected service features, but it can’t recreate the entire GCP environment. Some operations may be simplified, others may behave differently, and some simply haven’t been implemented.

In practice, that means an application that works correctly with Floci won’t necessarily behave identically when connected to Google Cloud.

Security is another consideration.

By default, the emulator doesn’t validate credentials in the same way Google does. So while we can test some permission-related mechanisms, we shouldn’t draw conclusions about production infrastructure security based on those tests.

There’s also little point in using Floci to benchmark the actual performance of GCP services.

Sure, we can measure the emulator’s response times and see how our application handles communication, but that won’t tell us what latency or limits we’ll encounter in Google Cloud.

Then there’s the project’s ongoing development. Floci isn’t an official Google product, so when GCP changes, it may take some time for those changes to appear in the emulator.

Is it worth the effort?

I think so, although it depends on the use case.

If we’re building an application that will eventually run on Cloud Run or GKE, being able to test parts of the deployment process and container runtime locally is pretty appealing.

The same applies to Cloud SQL, where we can work with a database container started by the emulator instead of relying on an external database instance.

Then there are services such as Cloud Storage and Pub/Sub, which can become components of a larger test environment.

For CI/CD, it makes a lot of sense. We can provision an environment, start the application, run integration tests, and clean everything up when the pipeline finishes.

On the other hand, if we want to test production infrastructure behavior, advanced IAM permissions, scaling, or real-world performance, Floci won’t replace actual GCP.

So I wouldn’t treat it as an alternative to Google Cloud, but rather as an additional tool that can make development and testing easier.

Summary

Floci GCP is an interesting option, especially if we work with applications that use Google Cloud services.

The ability to use native APIs, run containers locally, and automate test environments means it can be useful both in everyday development and in DevOps work.

Still, it isn’t a full replacement for Google Cloud. The supported functionality is limited, and the emulator won’t always behave exactly like the real services.

Is it worth it? I think so, especially for learning, experimenting, and integration testing. We just need to keep in mind what it was built for and not expect it to recreate Google’s entire infrastructure on our own computer.

← All posts