What is inner development loop?
Cloud-native technologies have significantly transformed the developer experience in two key aspects: Firstly, developers are now required to undertake additional steps within the inner development loop. Secondly, they must incorporate considerations of the outer development loop into their workflow, notwithstanding that the majority of their time is dedicated to the inner loop.
The inner development loop serves as the workflow for developers. They ought to proficiently establish and utilize an inner development loop to swiftly code and test changes.
The diagrams below illustrate the differences between the Traditional Inner Development Loop and the Container Inner Development Loop. The introduction of a new container build step represents a hidden cost, making it more expensive.
For more details, you can visit ambassador.
The best indicator of a healthy development workflow is a short feedback loop.
What are the current available options?
There are many tools and approaches available to improve the feedback loop, and here is a list (alphabetically sorted, no preference) of a few:
Enough theory, show me how to do it?
I intend to utilize ASP.NET Core Web App (Razor Pages) to develop a DEMO application, wherein I will investigate the functionality of Tilt and its effect on the feedback loop. In the subsequent days, I plan to conduct analogous assessments with various other tools.
# To create a DEMO app, execute below command from terminal
dotnet new razor -n tiltdemo
After successful creation of project, you can create docker file using Command Palette. (Refer below image).
The following code snippets outline the content of docker file.
# Dockerfile
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://+:8080
USER app
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG configuration=Release
WORKDIR /src
COPY ["tiltdemo.csproj", "./"]
RUN dotnet restore "tiltdemo.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "tiltdemo.csproj" -c $configuration -o /app/build
FROM build AS publish
ARG configuration=Release
RUN dotnet publish "tiltdemo.csproj" -c $configuration -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "tiltdemo.dll"]
The following code snippets outline the content of kubernetes file.
# tiltdemo-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: tiltdemo
spec:
replicas: 1
selector:
matchLabels:
app: tiltdemo
template:
metadata:
labels:
app: tiltdemo
spec:
containers:
- image: tiltdemo
name: tiltdemo
ports:
- containerPort: 8080
Now, we are ready with the DEMO app, Dockerfile, and Kubernetes file. Next step: setting up a Kubernetes Cluster for deploying the app. I'm using Rancher Desktop for this. Despite other options, sticking with Rancher for its ease of use. Here is the configuration's details:
Once the Kubernetes cluster is ready, our next step is to install Tilt and learn how to use it.
# To install tilt
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.ps1'))
# To run tilt, execute this command from terminal
tilt up
If the tilt file isn't found, the system prompts for its creation. It offers various other options too
- launch tilt UI (spacebar)
- to stream log (s)
- to open legacy terminal node (t)
- to exit (ctrl + c)
I recommend clearing the tiltfile's contents entirely and copying the code snippets provided below. While Tilt is running, you can continue updating files, and Tilt automates all the steps from a code change to new process: watching files, building image, deploying on cluster and keeping your environment up-to-date.
# Copy this code into tiltfile
docker_build('tiltdemo','.')
k8s_yaml('tiltdemo-deployment.yaml)
k8s_resource('tiltdemo', port_forwards='8080:8080')
After pressing spacebar, you can see Tilt Web UI is opened as
From the Tilt Web UI, you can see detailed logs and can open your application from endpoint column. For more information you can visit Tilt UI.
From Rancher Desktop, you can verify the cluster state.
# Use this command to delete resources created by 'tilt up'
tilt down
Let's Optimize further
Tilt provides various options to further Optimize the feedback loop e.g., compile project locally, copy build output files to container and most exciting option is Live Update, in which it will skip all intermediate steps and live-update the pod in place.
You can make below changes and see the impact.
# Update dockerfile with this content
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
COPY . /app/out
WORKDIR /app/out
ENTRYPOINT ["dotnet", "tiltdemo.dll"]
# Update tilt with this content
local_resource(
'build',
'dotnet publish -c Release -o out',
deps=['tiltdemo'],
ignore=['tiltdemo/obj'],
)
docker_build('tiltdemo', 'out', dockerfile='Dockerfile')
k8s_yaml('tiltdemo-deployment.yaml')
k8s_resource('tiltdemo', port_forwards='8080:8080', resource_deps=['build'])
NOTE: Live-Update is not covered in this blog. Readers can try it out on their own.