https://github.com/gbih/kubernetes-study-notes
"Kubernetes in Action" study notes
https://github.com/gbih/kubernetes-study-notes
go kubernetes shell
Last synced: about 2 months ago
JSON representation
"Kubernetes in Action" study notes
- Host: GitHub
- URL: https://github.com/gbih/kubernetes-study-notes
- Owner: gbih
- License: mit
- Created: 2020-09-28T11:38:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T09:04:49.000Z (almost 4 years ago)
- Last Synced: 2025-01-09T10:35:01.486Z (over 1 year ago)
- Topics: go, kubernetes, shell
- Language: Shell
- Homepage:
- Size: 36.3 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Study Notes for Kubernetes In Action, v1
1. Use multipass on OSX with microk8s
2. As much as possible, build Go demo programs (instead of Node.js)
3. Update any outdated or deprecated APIs
4. Eventually translate to Japanese
* Original source at:
[Kubernetes In Action, v1](https://www.manning.com/books/kubernetes-in-action)
------------
## Multipass installation and Ubuntu VM setup
* [Download Multipass installler](https://multipass.run)
* Install Ubuntu virtual instance via Multipass. Defaults include:
--cpus 1
--disk 5G
--mem 1G
```shell
multipass launch --name actionbook-vm --disk 50G
```
* Check VM info
```shell
multipass info actionbook-vm
```
## MicroK8s installation
* Log into multipass shell
```shell
multipass shell actionbook-vm
```
* Install MicroK8s
```shell
sudo snap install microk8s --classic --channel=1.19/stable
```
* We want to explore etcdctl later. Even though Microk8s 1.19 now uses dqlite as the default, we can revert to etcd by disabling ha-cluster:
```shell
microk8s.disable ha-cluster
sudo snap install etcd
```
* Add the user ubuntu to the 'microk8s' group:
```shell
sudo usermod -a -G microk8s ubuntu
sudo chown -f -R ubuntu ~/.kube
```
Then logout and login.
* Check the status while Kubernetes starts
```shell
microk8s status --wait-ready
microk8s config > microk8s.yaml
```
* Create alias
```shell
sudo snap alias microk8s.kubectl kubectl
```
* Turn on the services you want
```shell
microk8s enable dns storage ingress metallb
microk8s status
```
* Confirm running services
```
microk8s.inspect
```
-----------------------
## Docker installation
```shell
sudo apt-get update
sudo apt install docker.io
sudo docker version
sudo docker login --username **** --password ****
```
If you don't want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.
To create the docker group and add your user:
Create the docker group.
`sudo groupadd docker`
Add your user to the docker group.
`sudo usermod -aG docker $USER`
Log out and log in
`docker info`
* Test
`docker run busybox echo "Hello world"`
-----------------------
## Terminal setup
1. Shorten bash shell:
Add to ~/.bashrc
`vi ~/.bashrc`
`PS1='\W\$ '`
```shell
export PROMPT_DIRTRIM=1
PS1='\u:\W\$ '
```
????
Reload these scripts:
`source ~/.bashrc`
`source ~/.bash_profile`
2. Install resize
```shell
sudo apt-get update
sudo apt-get install xterm
sudo apt-get install rename
```
-----------------------
## Backup script
* Backup from multipass instance to host computer
Assuming you keep your work files on instance 'actionbook-vm' in the directory /home/ubuntu/src, create a tar.gz file and transfer it to a local host.
```shell
multipass exec actionbook-vm -- tar -cvzf /home/ubuntu/src.tar.gz /home/ubuntu/src && multipass transfer actionbook-vm:/home/ubuntu/src.tar.gz /Users/username/K8s-in-Action-Book/src
```
* Restore from host to multipass instance
```shell
multipass transfer /Users/username/Desktop/K8s-in-Action-Book/src.tar.gz actionbook-vm:/home/ubuntu/src/src.tar.gz
```
Note that multipass transfer requires the destination to be a file.
To extract a tar.gz file, use the --extract (-x) operator and specify the archive file name after the f option:
`tar -xvf src.tar.gz`
cd into install directory
`mv /home/ubuntu/install/home/ubuntu/src /home/ubuntu/src`
-----------------------
## Check Initial install:
Confirm file system layout and available disk space:
`df`
```shell
Filesystem 1K-blocks Used Available Use% Mounted on
udev 5103820 0 5103820 0% /dev
tmpfs 1023320 1092 1022228 1% /run
/dev/sda1 40470732 4272660 36181688 11% /
tmpfs 5116580 0 5116580 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 5116580 0 5116580 0% /sys/fs/cgroup
/dev/sda15 106858 3668 103190 4% /boot/efi
/dev/loop0 93568 93568 0 100% /snap/core/8689
/dev/loop1 196608 196608 0 100% /snap/microk8s/1293
```