catwarrior / catwarrior.github.io

This is my knowledge base.
0 stars 0 forks source link

pilot #35

Open catwarrior opened 7 years ago

catwarrior commented 7 years ago

install docker

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh -

catwarrior commented 7 years ago

http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/help

Docker daemon config

https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file

catwarrior commented 7 years ago

create rancher vm

sudo rm /etc/apt/sources.list sudo touch /etc/apt/sources.list echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list

curl -sSL http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet | sh /dev/stdin 1.12.3

echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=https://iakbs8nw.mirror.aliyuncs.com\"" | sudo tee -a /etc/default/docker sudo service docker restart

sudo docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.1 http://192.168.1.108:8080/v1/scripts/19254A288A51C147D903:1483142400000:emuHDL3Zpg0shEtFRwX8OKHwHSM

Tips

clean up volume map which prevent delete folder. cat /proc/mounts | grep "rancher" | awk '{print $2}' sudo umount /var/lib/rancher/volumes

sudo umount $(cat /proc/mounts | grep "rancher" | awk '{print $2}')

catwarrior commented 7 years ago

asp.net core / jenkins / docker

https://www.pgs-soft.com/cross-platform-application-using-net-core-jenkins-docker/

https://wannabeegeek.com/2016/12/13/creating-a-simple-containerized-ci-workflow-for-asp-net-core-apps/

jenkins

building, testing and reporting

update center url mirror https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json

gogs webhook: ??http://ci.mbcpa.com/gogs-webhook?job=netcore PayloadURL: http://jenkins:8080/gogs-webhook/?job=netcore ContentType: application/json Secret: 1 ![Uploading image.png…]()

Gogs

https://github.com/gogits/gogs/tree/master/docker

https://medium.com/@denmaseno/serving-git-server-with-gogs-docker-5a8d37c3c153#.tacc933iy

https://opsnotice.xyz/gogs-git-docker/

install docker compose

curl -L https://mirrors.aliyun.com/docker-toolbox/linux/compose/1.11.2/docker-compose-Linux-x86_64 > docker-compose chmod +x docker-compose sudo mv docker-compose /usr/local/bin/docker-compose

Or

sudo -i curl -L "https://github.com/docker/compose/releases/download/1.11.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose exit

SUSE

docker mirror /etc/docker/daemon.json { "registry-mirrors": ["https://iakbs8nw.mirror.aliyuncs.com"], "insecure-registries": ["42.159.29.145:18083"], "graph": "/mnt/docker-data", "storage-driver": "overlay2" }

sudo systemctl restart docker.service

sudo systemctl enable docker.service # start docker daemon at boot

Add user to sudoers https://www.suse.com/communities/blog/create-user-administrator-suse-linux-enterprise-server-11/

visudo

Docker

To accomplish this, set the following flags in the daemon.json file: { "graph": "/mnt/docker-data", "storage-driver": "overlay" } https://docs.docker.com/engine/admin/systemd/#runtime-directory-and-storage-driver

private registry option on rancher

http://rancher.com/create-a-private-docker-registry-to-integrate-with-rancher/

clean up docker images

docker rmi $(docker images -f "dangline=true" -q

catwarrior commented 7 years ago

version: '2' services: lb: image: jwilder/nginx-proxy container_name: lb volumes:

volumes: gogsData: {} jenkinsData: {} nexusData: {}

catwarrior commented 7 years ago

CI/CD

jenkins

sudo zypper addrepo http://pkg.jenkins-ci.org/opensuse/ jenkins sudo zypper install jenkins sudo /etc/init.d/jenkins jenkins start

add jenkins to docker group

sudo usermod -aG docker jenkins

https://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch03s07.html

build inside container

https://store.docker.com/community/images/microsoft/aspnetcore-build

catwarrior commented 7 years ago

sudo usermod -aG docker $USER mkdir -p /etc/docker/daemon.json /etc/docker/daemon.json { "registry-mirrors": ["https://iakbs8nw.mirror.aliyuncs.com"], "insecure-registries":["docker.pilot.mbafc.com"] }

sudo systemctl restart docker.service

catwarrior commented 7 years ago

Ansible

zypper addrepo http://download.opensuse.org/repositories/systemsmanagement/SLE_12_SP2/systemsmanagement.repo zypper refresh zypper install ansible

SUSE repo http://software.opensuse.org/download.html?project=systemsmanagement&package=ansible

ansible ssh

http://www.cyberciti.biz/python-tutorials/linux-tutorial-install-ansible-configuration-management-and-it-automation-tool/

catwarrior commented 7 years ago

kubernetes

New deployment

kubectl run my-nginx --image=nginx --labels="run=load-balancer-example" --replicas=2 --port=80

New Service

kubectl expose deployment my-nginx --type=NodePort --name=example-service

Access the service

kubectl describe services example-service output: NodePort: <unset> 30755/TCP

so: http://node_public_ip:30755 will be the url of example-service.

https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address-service/

Kubectl commands:

https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/

kubectl --kubeconfig='configpath' balabala

look into kubectl

kubectl get events --namespace=kube-system

how to solve image pull error from google. https://docs.rancher.com/rancher/v1.5/en/kubernetes/private-registry/ https://github.com/rancher/kubernetes-package/tree/master/addon-templates

http://www.07net01.com/2017/01/1773267.html images=(kube-proxy-amd64:v1.5.1 kube-discovery-amd64:1.0 kubedns-amd64:1.9 kube-scheduler-amd64:v1.5.1 kube-controller-manager-amd64:v1.5.1 kube-apiserver-amd64:v1.5.1 etcd-amd64:3.0.14-kubeadm kube-dnsmasq-amd64:1.4 exechealthz-amd64:1.2 pause-amd64:3.0 kubernetes-dashboard-amd64:v1.5.0 dnsmasq-metrics-amd64:1.0) for imageName in ${images[@]} ; do docker pull jicki/$imageName docker tag jicki/$imageName gcr.io/google_containers/$imageName docker rmi jicki/$imageName done

https://hub.docker.com/r/ist0ne/kubernetes-dashboard-amd64/

` this one works. images=(kube-proxy-amd64:v1.5.1 kube-discovery-amd64:1.0 kubedns-amd64:1.9 kube-scheduler-amd64:v1.5.1 kube-controller-manager-amd64:v1.5.1 kube-apiserver-amd64:v1.5.1 etcd-amd64:3.0.14-kubeadm kube-dnsmasq-amd64:1.4 exechealthz-amd64:1.2 pause-amd64:3.0 kubernetes-dashboard-amd64:v1.5.0 dnsmasq-metrics-amd64:1.0) for imageName in ${images[@]} ; do docker pull jicki/$imageName docker tag jicki/$imageName gcr.io/google_containers/$imageName docker rmi jicki/$imageName done

images=(kube-proxy-amd64:v1.5.3 kube-scheduler-amd64:v1.5.3 kube-controller-manager-amd64:v1.5.3 kube-apiserver-amd64:v1.5.3 etcd-amd64:3.0.14-kubeadm kube-discovery-amd64:1.0 pause-amd64:3.0 kubedns-amd64:1.9 dnsmasq-metrics-amd64:1.0 kube-dnsmasq-amd64:1.4 exechealthz-amd64:1.2) for imageName in ${images[@]} ; do docker pull ist0ne/$imageName docker tag ist0ne/$imageName gcr.io/google_containers/$imageName docker rmi ist0ne/$imageName done

images=(kube-proxy-amd64:v1.5.1 kube-discovery-amd64:1.0 kubedns-amd64:1.9 kube-scheduler-amd64:v1.5.1 kube-controller-manager-amd64:v1.5.1 kube-apiserver-amd64:v1.5.1 etcd-amd64:3.0.14-kubeadm kube-dnsmasq-amd64:1.4 exechealthz-amd64:1.2 pause-amd64:3.0 dnsmasq-metrics-amd64:1.0) for imageName in ${images[@]} ; do docker pull ist0ne/$imageName docker tag ist0ne/$imageName 42.159.29.145:18083/google_containers/$imageName docker rmi ist0ne/$imageName docker push 42.159.29.145:18083/google_containers/$imageName docker rmi 42.159.29.145:18083/google_containers/$imageName done

images=(tiller:v2.1.3) for imageName in ${images[@]} ; do docker pull ist0ne/$imageName docker tag ist0ne/$imageName 42.159.29.145:18083/kubernetes-helm/$imageName docker rmi ist0ne/$imageName docker push 42.159.29.145:18083/kubernetes-helm/$imageName docker rmi 42.159.29.145:18083/kubernetes-helm/$imageName done

images=(heapster:v1.2.0 heapster_grafana:v2.6.0-2 kubernetes-dashboard-amd64:v1.5.0) for imageName in ${images[@]} ; do docker pull ist0ne/$imageName docker tag ist0ne/$imageName 42.159.29.145:18083/google_containers/$imageName docker rmi ist0ne/$imageName docker push 42.159.29.145:18083/google_containers/$imageName docker rmi 42.159.29.145:18083/google_containers/$imageName done

images=(heapster_influxdb:v0.5) for imageName in ${images[@]} ; do docker pull kubernetes/$imageName docker tag kubernetes/$imageName 42.159.29.145:18083/kubernetes/$imageName docker rmi kubernetes/$imageName docker push 42.159.29.145:18083/kubernetes/$imageName docker rmi 42.159.29.145:18083/kubernetes/$imageName done `

https://yq.aliyun.com/articles/68921

Kubedashboard troubleshooting

https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md

http://rootsongjc.github.io/tags/kubernetes/

catwarrior commented 7 years ago

Azure

Deployment Model

https://docs.microsoft.com/zh-cn/azure/azure-resource-manager/resource-manager-deployment-model

Azure cli 1.0

microsoft/azure-cli https://docs.microsoft.com/en-us/azure/cli-install-nodejs https://docs.microsoft.com/en-us/azure/virtual-machines/azure-cli-arm-commands#azure-storage-commands-to-manage-your-storage-objects https://github.com/Azure/azure-xplat-cli usage: docker run -it microsoft/azure-cli

Azure CLI 2.0

azuresdk/azure-cli-python:latest https://docs.microsoft.com/en-us/cli/azure/overview https://github.com/Azure/azure-cli usage: docker run -v ${HOME}:/root -it azuresdk/azure-cli-python:latest

https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-get-started-connect-with-cli usage: az cloud set --name AzureUSGovernment az login --username your-user-name@your-gov-tenant.onmicrosoft.com az cloud list --output table

Sample script: https://docs.microsoft.com/en-us/azure/virtual-machines/scripts/virtual-machines-linux-cli-sample-create-vm-nsg?toc=%2fcli%2fazure%2ftoc.json https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-samples?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json

Diff between 1.0 and 2.0

https://github.com/Azure/azure-cli/blob/master/doc/azure2az_commands.rst

https://docs.microsoft.com/en-us/azure/virtual-machines/linux/upload-vhd

Azure Application Gateway

application gateway / load balance https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-multi-site-overview https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-create-multisite-azureresourcemanager-powershell

https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-faq

https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-probe-overview

Kubernetes on Azure

https://docs.microsoft.com/en-us/azure/container-service/container-service-kubernetes-walkthrough

Create VM from template

http://www.cnblogs.com/hengwei/p/6699331.html

Resource Manager (RM) templates.

https://docs.microsoft.com/en-us/azure/azure-resource-manager/best-practices-resource-manager-design-templates https://docs.microsoft.com/en-us/azure/container-service/container-service-kubernetes-walkthrough https://www.azure.cn/documentation/articles/azure-cli-arm-commands/ https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-specialized-vhd-existing-vnet

Azure china

https://www.azure.cn/documentation/articles/virtual-machine-scale-sets-design-overview/

VM Scaleset

https://www.azure.cn/documentation/articles/virtual-machine-scale-sets-cli-quick-create/

https://forums.rancher.com/t/local-ip-for-rancher-agent-with-scale-sets/1836 https://github.com/Azure/azure-quickstart-templates/tree/master/docker-rancher

https://github.com/rancher/rancher/issues/3745 https://github.com/rancher/rancher/issues/3746

https://hub.docker.com/r/wmbutler/rancher-purge/

az group create -n vmssrg -l chinanorth az vmss create --name rancher --resource-group vmssrg --location chinanorth --instance-count 2 --vm-sku Standard_D1_v2 \ --authentication-type password --admin-username myadmin --admin-password Admin@1234567890 \ --use-unmanaged-disk --storage-sku Standard_LRS \ --image SUSE:SLES:12-SP2:2017.03.20 --output table \ --custom-data /root/custom-data.yaml

az group create -n vmssrg1 -l chinanorth az vmss create --name rancher1 --resource-group vmssrg1 --location chinanorth --instance-count 2 --vm-sku Standard_D1_v2 \ --authentication-type password --admin-username myadmin --admin-password Admin@1234567890 \ --use-unmanaged-disk --storage-sku Standard_LRS \ --image SUSE:SLES:12-SP2:2017.03.20 --output table \ --custom-data /root/custom-data.yaml

az group create -n vmssrg2 -l chinanorth az vmss create --name rancher2 --resource-group vmssrg2 --location chinanorth --instance-count 2 --vm-sku Standard_D1_v2 \ --authentication-type password --admin-username myadmin --admin-password Admin@1234567890 \ --use-unmanaged-disk --storage-sku Standard_LRS \ --image SUSE:SLES:12-SP2:2017.03.20 --output table \ --custom-data /root/custom-data.yaml

catwarrior commented 7 years ago

To be check!!!!! https://cloud.google.com/solutions/automated-build-images-with-jenkins-kubernetes

catwarrior commented 7 years ago

Logging and Monitoring

zipkin https://github.com/criteo/zipkin4net

https://github.com/rancher/community-catalog/tree/master/kubernetes-templates/Prometheus/0

Generate test request.

while sleep 1 ; do for n in {0..$(((RANDOM % 10) + 1))} ; do curl -s -A $n localhost &>/dev/null ; done ; done

catwarrior commented 7 years ago

Checkout all branches to local branches;

for branch in git branch -a | grep remotes | grep -v HEAD | grep -v master; do git branch --track ${branch##*/} $branch; done