kubectl - Kubernetes CLI client

Client
sudo apt-get update
sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl kubeadm

Bash completion
kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl

Manual installation

OpenStack: Magnum

openstack coe service list
openstack stack list
openstack stack show d8a1c3af-7993-4493-91be-19cfce38a870
openstack coe cluster update k8s-cluster replace node_count=2

Configure deployment kolla-ansible
# cat /etc/kolla/config/magnum.conf
[cinder]
default_docker_volume_type = VT1

[trust]
cluster_user_trust = True

/etc/kolla/config/heat.conf
[DEFAULT]
#region_name = ch-zh1
region_name_for_services = RegionOne

# /etc/kolla/globals.yml
# magnum_tag: "7.0.0.1"
enable_magnum: "yes"

Redeploy / Reconfigure container

Kubernetes dashboard UI

Add user and configure permissions
cat < /tmp/dashboard-adminuser.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kube-system
EOF
kubectl apply -f /tmp/dashboard-adminuser.yaml

cat < /tmp/kubernetes-dashboard-admin.rbac.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kube-system
EOF

Visual Studio Code

# deb download
# https://code.visualstudio.com/docs/setup/linux
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install code # or code-insiders

# manual download
wget -q https://update.code.visualstudio.com/latest/linux-deb-x64/stable -O /tmp/code.deb

Snap (Ubuntu package management)

Install
sudo apt install -y snapd

CLI
snap find
snap install

Configure proxy
sudo mkdir -p /etc/systemd/system/snapd.service.d/
echo -e '[Service]\nEnvironment="http_proxy=http://proxy.example.com:3128/"' | sudo tee /etc/systemd/system/snapd.service.d/http-proxy.conf
echo -e '[Service]\nEnvironment="https_proxy=http://proxy.example.com:3128/"' | sudo tee /etc/systemd/system/snapd.service.d/https-proxy.conf
sudo systemctl daemon-reload
sudo systemctl restart snapd

# debug proxy
systemctl show snapd | grep proxy

OpenStack: Application credentials

Create applications credentials
openstack application credential create admin --role admin --expiration $(date -I -d '+1 month')T23:59:59 -c id -c secret #-f value

Configure clouds.yml
# ~/.config/openstack/clouds.yaml
clouds:
dev-app:
auth_type: "v3applicationcredential"
auth:
auth_url: https://keystone.example.com/v3
application_credential_id: "b9275fc5b3aadceeb407fbe941427425"
application_credential_secret: "HqfdfKk3q63xrnIZgdkizePfv1s27aYPBTrbiMKFNdrOU1JpdjfR0KSyomS4A01vSdxjkE9MzPuM4dVG7emWuA"

Open vSwitch (OVS)

Create
ovs-vsctl -- --may-exist add-port br-int o-hm0 -- \
set Interface o-hm0 type=internal -- \
set Interface o-hm0 external-ids:iface-status=active -- \
set Interface o-hm0 external-ids:attached-mac=${CTL_HOST_MAC} -- \
set Interface o-hm0 external-ids:iface-id=${PORT_ID} -- \
set Interface o-hm0 external-ids:skip_cleanup=true

Delete
ovs-vsctl -- del-port br-int o-hm0

Create port
openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int my-port1 -- \
set Interface o-hm0 type=internal -- \

OpenStack: Glance (Image)

Deaktivate image
IMAGE_NAME="Ubuntu 14.04"
openstack image list --status active --name "${IMAGE_NAME}" -c ID -f value | xargs openstack image set --deactivate --private
openstack image list --status active

List the images
openstack image list

Delete all images
for IMAGE in $(openstack image list -c ID -f value); do
openstack image set --unprotected ${IMAGE}
openstack image delete ${IMAGE}
done

Delete image
IMAGE_NAME="Ubuntu 16.04"
openstack image set --unprotected ${IMAGE_NAME}