Using PFS with Windows

This topic provides help for using PFS with Windows and running commands in Windows PowerShell. These docs assume Windows 10 Pro, which includes PowerShell v5.1 and supports Hyper-V.

Disable pfs CLI colors in PowerShell

pfs CLI colors are not compatible with PowerShell. To disable pfs CLI colors in PowerShell run:

Add-Content -Path $env:USERPROFILE\.pfs.yaml -Value 'no-color: true'

PowerShell variables

PowerShell variable names are prefixed with $ and otionally enclosed in {}. Literal strings are enclosed in single or double quotes. Double quotes support variable interpolation. E.g.

$NAME = 'PFS'
echo "Hello $NAME or Delimited ${NAME}WithBraces"
Hello PFS or Delimited PFSWithBraces

Environment variables in PowerShell

Environment variables are available to other shells and processes E.g. The duffle CLI expects SERVICE_ACCOUNT and KUBE_NAMESPACE environment variables when installing with the kubernetes driver. PowerShell environment variables are prefixed with $Env: E.g.

$Env:SERVICE_ACCOUNT = 'duffle-runtime'
$Env:KUBE_NAMESPACE = 'duffle'

Multi-line commands in PowerShell

Commands can span multiple lines by escaping the line terminator with a backtick ` E.g.

duffle install my-pfs `
  c:\Users\hello\pfs\pfs-bundle-thick.tgz --bundle-is-file `
  --relocation-mapping c:\Users\hello\pfs\pfs-relmap.json `
  --driver k8s `
  --set node_port=true

Install curl

The open source version of curl can be installed from an Admin PowerShell using choco install curl which assumes Chocolatey.

Remove the built-in PowerShell curl alias with Remove-item alias:curl.

curl --version
curl 7.55.1 (Windows) libcurl/7.55.1 WinSSL
...

Watch

This PowerShell function will call kubectl get every 3 seconds.

function watchpods { while(1){ kubectl get pod --all-namespaces; start-sleep -seconds 3; clear }}

If you have git bash installed, you can achieve the same result (but with less flashing of the screen) by creating a bash script called watch:

#!/bin/bash
ARGS="${@}"
clear;
while(true); do
  OUTPUT=`$ARGS`
  clear
  echo -e "${OUTPUT[@]}"
  sleep 1
done

Then to watch all pods from git bash:

watch kubectl get pod --all-namespaces