Skip to content

Commit

Permalink
chore: pre v0.5.0 cleanups (#513)
Browse files Browse the repository at this point in the history
* k3s: enable cni for cri-dockerd

* docs: prepare for v0.5.0

* chore: refactor dns hosts

* docs: update FAQ
  • Loading branch information
abiosoft authored Dec 15, 2022
1 parent 20ba5dd commit 5a94ab4
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func init() {
startCmd.Flags().StringToStringVar(&startCmdArgs.Env, "env", nil, "environment variables for the VM")

// dns
startCmd.Flags().IPSliceVarP(&startCmdArgs.Network.DNSResolvers, "dns", "n", nil, "DNSResolvers servers for the VM")
startCmd.Flags().StringSliceVarP(&startCmdArgs.Flags.DNSHosts, "dns-host", "", nil, "Custom DNS names to provide to resolver")
startCmd.Flags().IPSliceVarP(&startCmdArgs.Network.DNSResolvers, "dns", "n", nil, "DNS resolvers for the VM")
startCmd.Flags().StringSliceVar(&startCmdArgs.Flags.DNSHosts, "dns-host", nil, "Custom DNS names to provide to resolver")
}

func dnsHostsFromFlag(hosts []string) map[string]string {
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type Kubernetes struct {
type Network struct {
Address bool `yaml:"address"`
DNSResolvers []net.IP `yaml:"dns"`
DNSHosts map[string]string `yaml:"dns_hosts"`
DNSHosts map[string]string `yaml:"dnsHosts"`
}

// Mount is volume mount
Expand Down
37 changes: 29 additions & 8 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
- [Accessing the underlying Virtual Machine](#accessing-the-underlying-virtual-machine)
- [The Virtual Machine's IP is not reachable](#the-virtual-machines-ip-is-not-reachable)
- [Enable reachable IP address](#enable-reachable-ip-address)
- [How can disk space be recovered?](#how-can-disk-space-be-recovered)
- [Automatic](#automatic)
- [Manual](#manual)
- [Are Lima overrides supported?](#are-lima-overrides-supported)

## How does Colima compare to Lima?
Expand Down Expand Up @@ -107,7 +110,7 @@ docker context use <context-name>
```
### Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Colima uses Docker contexts to allow co-existence with other Docker servers and sets itself as the default Docker context on startup.
Colima uses Docker contexts to allow co-existence with other Docker servers and sets itself as the default Docker context on startup.

However, some applications are not aware of Docker contexts and may lead to the error.

Expand All @@ -120,7 +123,7 @@ This can be fixed by any of the following approaches. Ensure the Docker socket p
```sh
export DOCKER_HOST="unix://${HOME}/.colima/default/docker.sock"
```
3. Linking the Colima socket to the default socket path. **Note** that this may break other Docker servers.
3. Linking the Colima socket to the default socket path. **Note** that this may break other Docker servers.

```sh
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
Expand All @@ -133,24 +136,24 @@ This can be fixed by any of the following approaches. Ensure the Docker socket p

On first startup, Colima generates Docker daemon.json file at `$HOME/.colima/docker/daemon.json`.
Modify the daemon.json file accordingly and restart Colima.

* v0.4.0 or newer

Start Colima with `--edit` flag.

```sh
colima start --edit
```

Add the Docker config to the `docker` section.

```diff
- docker: {}
+ docker:
+ insecure-registries:
+ - myregistry.com:5000
+ - host.docker.internal:5000
```
```

### Docker plugins are missing (buildx, scan)

Expand Down Expand Up @@ -236,7 +239,7 @@ The underlying Virtual Machine is still accessible by specifying `--layer=false`

## The Virtual Machine's IP is not reachable

This is by design. Reachable IP address is not enabled by default because it requires root access.
Reachable IP address is not enabled by default due to slower startup time.

### Enable reachable IP address

Expand All @@ -253,6 +256,24 @@ This is by design. Reachable IP address is not enabled by default because it req
+ address: true
```

## How can disk space be recovered?

Disk space can be freed in the VM by removing containers or running `docker system prune`.
However, it will not reflect on the host on Colima versions v0.4.x or lower.

### Automatic

For Colima v0.5.0 and above, unused disk space in the VM is released on startup. A restart would suffice.

### Manual

For Colima v0.5.0 and above, user can manually recover the disk space by running `sudo fstrim -a` in the VM.

```sh
# '-v' may be added for verbose output
colima ssh -- sudo fstrim -a
```

## Are Lima overrides supported?

Yes, however this should only be done by advanced users.
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Binaries are available with every release on the [releases page](https://github.

```sh
# download binary
curl -LO https://github.com/abiosoft/colima/releases/download/v0.4.0/colima-$(uname)-$(uname -m)
curl -LO https://github.com/abiosoft/colima/releases/download/v0.5.0/colima-$(uname)-$(uname -m)

# install in $PATH
install colima-$(uname)-$(uname -m) /usr/local/bin/colima # or sudo install if /usr/local/bin requires root.
Expand Down
13 changes: 9 additions & 4 deletions embedded/defaults/colima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ network:
# DNS hostnames to resolve to custom targets using the internal Lima resolver.
# This setting has no effect if a custom DNS resolver list is supplied above.
# It does not configure the /etc/hosts files of any machine or container.
dns_hosts:
# The value can be an IP address or another host.
#
# EXAMPLE
# dnsHosts:
# example.com: 1.2.3.4
dnsHosts:
host.docker.internal: host.lima.internal

# ===================================================================== #
Expand Down Expand Up @@ -130,12 +135,12 @@ layer: false
# Custom provision scripts for the virtual machine.
# Provisioning scripts are executed on startup and therefore needs to be idempotent.
#
# Example - script exected as root
# EXAMPLE - script exected as root
# provision:
# - mode: system
# script: apk add htop vim
#
# Example - script exected as user
# EXAMPLE - script exected as user
# provision:
# - mode: user
# script: |
Expand Down Expand Up @@ -174,4 +179,4 @@ mounts: []
# ANOTHER_KEY: another value
#
# Default: {}
env: {}
env: {}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/abiosoft/colima/environment"
)

func installContainerdDeps(guest environment.GuestActions, a *cli.ActiveCommandChain) {
func installCniConfig(guest environment.GuestActions, a *cli.ActiveCommandChain) {
// fix cni config
a.Add(func() error {
flannelFile := "/etc/cni/net.d/10-flannel.conflist"
Expand Down
16 changes: 9 additions & 7 deletions environment/container/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ func (c *kubernetesRuntime) Provision(ctx context.Context) error {
}

// this needs to happen on each startup
switch runtime {
case containerd.Name:
installContainerdDeps(c.guest, a)
case docker.Name:
a.Retry("waiting for docker cri", time.Second*2, 5, func(int) error {
return c.guest.Run("sudo", "service", "cri-dockerd", "start")
})
{
// cni is used by both cri-dockerd and containerd
installCniConfig(c.guest, a)

if runtime == docker.Name {
a.Retry("waiting for docker cri", time.Second*2, 5, func(int) error {
return c.guest.Run("sudo", "service", "cri-dockerd", "start")
})
}
}

// provision successful, now we can persist the version
Expand Down

0 comments on commit 5a94ab4

Please sign in to comment.