Skip to content

Instantly share code, notes, and snippets.

@gabriel-samfira
gabriel-samfira / watcher.go
Created February 2, 2024 13:44
Make an average of newly created files
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"path/filepath"
"sync/atomic"
@gabriel-samfira
gabriel-samfira / setup_buildkit_on_windows.md
Created August 31, 2023 13:15
Install Buildkitd on Windows

Installing buildkit on Windows from source

This will set up buildkitd natively on Windows Server 2019 (ltsc2019) or Windows Server 2022 (ltsc2022).

Enable the containers feature

This will reboot your server if the feature is not already installed.

Install-WindowsFeature -Name containers -Restart
@gabriel-samfira
gabriel-samfira / setup_buildkitd_on_windows.ps1
Last active February 1, 2024 08:42
Install buildkitd on Windows
$ErrorActionPreference="Stop"
$containerdDir = join-path $env:ProgramFiles containerd
if (!(Test-Path $containerdDir)){
mkdir $containerdDir
}
$downloadPath = Join-Path $env:Tmp "containerd.tar.gz"
$downloadLink = "https://github.com/containerd/containerd/releases/download/v1.7.5/containerd-1.7.5-windows-amd64.tar.gz"
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/Microsoft/go-winio"
"golang.org/x/sys/windows"
C:\Users\Administrator\work\playground\with-drive-letter>docker build -t docker.samfira.com/volume-copy-up:2.6 .
Sending build context to Docker daemon 5.253MB
Step 1/19 : FROM mcr.microsoft.com/windows/nanoserver:ltsc2022
ltsc2022: Pulling from windows/nanoserver
9e0d440fca83: Already exists
Digest: sha256:3bb312dcc36fa551766a13cf2fb8e2be90726774589c96bea9198a26307bf2a2
Status: Downloaded newer image for mcr.microsoft.com/windows/nanoserver:ltsc2022
---> 0c7fb865d8dc
Step 2/19 : ADD https://github.com/kubernetes-sigs/windows-testing/raw/3fea3d48ea8337b2aaca755c1d719e34b45f46b9/images/busybox/busybox.exe /bin/busybox.exe
Downloading [==================================================>] 575kB/575kB
# Copyright The containerd Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,

Local test env of k8s and containerd (the hard way)

Assumptions:

  • You're running on an ubuntu 20.04 VM/physical server
  • Your IP address is: 10.198.117.162 (obviously you will need to adust this to your env)
  • The hostname of the machine is k8s-test
  • The windows node we'll be adding is a Windows Server 2022 (ltsc2022)

Obviously you will need to adust these assumptions to your env. But for clarity we define these assumptions here.

@gabriel-samfira
gabriel-samfira / setup_env.md
Last active June 3, 2022 12:24
Prepare a Windows server machine for containerd tests

Intro

The scripts in this gist are mostly taken from the containerd repo with some small changes. Feel free to inspect them and see what they do.

Install required features

# If the feature is not already installed, this will install it
# and reboot your machine.
Install-WindowsFeature -Name Containers -Restart
$ErrorActionPreference="Stop"
# Considerable performance boost withour realtime monitoring.
# This is usually okay on temporary test systems. Don't do this
# on your own machine.
Set-MpPreference -DisableRealtimeMonitoring:$true
wget -UseBasicParsing -OutFile "$HOME\prepare_env_windows.ps1" -Uri https://gist.githubusercontent.com/gabriel-samfira/c80ccb1d79be737e5e61214181e48ad8/raw/4aa3d3efe643f70c9b8bcd139b3afca798900262/prepare_env_windows.ps1
& "$HOME\prepare_env_windows.ps1"
@gabriel-samfira
gabriel-samfira / prepare_env_windows.ps1
Last active August 31, 2023 11:08
Installs needed dependencies
# Prepare windows environment for building and running containerd tests
$PACKAGES= @{ mingw = "12.2.0"; git = ""; golang = ""; make = ""}
Write-Host "Downloading chocolatey package"
curl.exe -L "https://packages.chocolatey.org/chocolatey.0.10.15.nupkg" -o 'c:\choco.zip'
Expand-Archive "c:\choco.zip" -DestinationPath "c:\choco"
Write-Host "Installing choco"
& "c:\choco\tools\chocolateyInstall.ps1"