If my team has 10 microservices, and we want to ru...
# server
s
If my team has 10 microservices, and we want to run the entire product suite locally on our computer, what's the best way to do that? Something like
docker-compose
becomes extremely inconvenient as soon as you want to turn off a service and run your own local dev environment. Surely there is a tool that I just don't know about that everyone is using to manage their environments?
s
today i learned 2
👍 1
s
@Sam Thank you. this is exactly the kind of thing I was looking for
🐕 1
c
https://fluxcd.io and https://kind.sigs.k8s.io is a combination I like
s
So at some point building everything locally just isn't an option. I was hoping I could just have it run docker containers, or tell it to instead of running the docker container build it locally
c
kubernetes is the standard way to run a group of docker containers together. and it can be almost as simple as docker compose
that said it is a can of worms that once opened can keep you busy for a long time
s
@christophsturm How easy or difficult is it to turn off the container so that you can develop?
c
you mean run one microservice in your ide and the others in kubernetes to test them together?
s
yes. But each team would want to change which microservice was comiled locally vs run with docker. It would need to be easily configurable. Surely this is a common problem
s
☝️ we do exactly this with tilt 👍
s
I'm currently reading the tilt documentation
@Sam How do you express and choose for a resource whether or not you are building it locally or running the docker image?
c
my projects are strictly gitops so we use flux and kind. but we also don’t test things in the IDE, we have unit tests, integration tests and e2e tests. so everything can be tested in isolation and when you build the cluster you only need to test if it all fits together via the e2e tests.
c
To proxy a local service when developing on Kubernetes, you can use the
kubectl
command-line tool to create a proxy that forwards traffic to the local service. To create a proxy to a local service, use the
kubectl proxy
command, which will start a local proxy server that listens on port 8001 by default. For example, to create a proxy to a local service called
my-service
, you can run the following command:
Copy code
kubectl proxy --port=8001 --service=my-service
This command will create a proxy that forwards traffic to the
my-service
service on port 8001. Once the proxy is running, you can access the service by using the
localhost
hostname and the specified port (in this example, 8001) in your browser or application. Alternatively, you can use the
kubectl port-forward
command to forward traffic from a local port to a port on the Kubernetes cluster. For example, to forward traffic from local port 8080 to port 80 on the
my-service
service, you can run the following command:
Copy code
kubectl port-forward --service=my-service 8080:80
This command will forward traffic from local port 8080 to port 80 on the
my-service
service, allowing you to access the service using the
localhost
hostname and the specified local port (in this example, 8080) in your browser or application. Both of these methods allow you to access a local service when developing on Kubernetes, and can be useful for testing and debugging your application.
1
At leas thats what openai.chat tells me 🤷‍♂️
🤦 1
😂 3
c
yeah testing with kubectl port forwards is always possible but it grows out of hand quickly. the most important thing when working with kubernetes is to avoid complexity, its lurking everywhere.
so trying to do only things that also work on a local kind cluster is a good rule of thumb to avoid complexity
s
Tilt seems like the closest solution to what I'm actually looking to do
c
we've had pretty good luck so far with k8s, and only deploying groups of services that we are actively working on
I'm sure that will eventually get out of hand and we'll need to use proxies and find better tooling
but that day has not yet come
c
I recommend k9s and lens, two really nice UIs for kubernetes
c
we use k9s, its pretty great
s
what is k9s?
c
will take a peek at lens
c
lens is basiclly the same but with a graphic ui
k9s is a ncurses ui for k8s
s
How do you express and choose for a resource whether or not you are building it locally or running the docker image?
I’m not sure, but I know it’s possible, because we do it. Somebody other than me was responsible for setting it all up 😄
c
wait... watching a video on lens now
Do people actually pronounce kubectl as COOB CTL
yes black 2
s
is there another way?
c
@____@ My life is a lie
s
I don't use kubernetes, but that's what I say in my head
c
like controlling a cube 🙂
c
I think Cube Ctl
lol
j
If they are mostly in kotlin, why not just run them all/most of them in the same JVM?
j
We have a docker-compose setup that can build/run everything. Then we have some helper scripts to start various parts of the app. Then we just run whatever service we're devining on locally in IDEA and don't start that particular container.
t
is this a Service Virtualization talk? What about something like WireMock/MitmProxy in front of your 'other' microservices?
h
In our practice, we separate the logic part of microservices from the deployment part, so that we can run all microservices in an Application (Sisyphus Project Structure).
s
Just to follow up on this - tilt is EXACTLY what I was looking for. It's very customizable, as its options and resources are expressed in code, not configuration, and it offers pretty good customization. So far I'm very impressed with it.
🎉 1
t
Curious, why is
docker compose
inconvenient when you want to turn of a service? You'd just do
docker compose stop name-of-the-service
and then startup the local one
s
So docker compose is just not a very convenient experience. I recommend trying tilt. It's actually SUPER easy to hook it up to docker compose:
Copy code
docker_compose('path-to/docker-compose.yml')
Tilt is an application with a UI that manages your services. I think it's pretty fantastic.
t
So could you for example start/stop services defined in the
docker.compose.yml
using the UI?
s
Tilt can run my service for me from a docker container (meaning I don't need to build it, start gradle or any of that nonsense. It's fast and cheap.
Or with a single click, I can have it run the service locally from gradle
I've got one place for logs
it's just a significantly better dev experience. docker-compose is very limited
t
Sounds interesting, if it can live with docker compose but does not need to be strictly required in a project. So that some devs could use it if they want, and other's could just use docker compose as is