Resource configuration backup
kunectl get all —all-namespaces -o yaml > all-deploy-service.yaml

etcd backup n restore
복구시
token n data 경로는 원래 것과 다르게 해야한다

# 1. Get etcdctl utility if it's not already present.

Reference: https://github.com/etcd-io/etcd/releases

```
ETCD_VER=v3.3.13

# choose either URL
GOOGLE_URL=https://storage.googleapis.com/etcd
GITHUB_URL=https://github.com/etcd-io/etcd/releases/download
DOWNLOAD_URL=${GOOGLE_URL}

rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
rm -rf /tmp/etcd-download-test && mkdir -p /tmp/etcd-download-test

curl -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz
tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /tmp/etcd-download-test --strip-components=1
rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz

/tmp/etcd-download-test/etcd --version
ETCDCTL_API=3 /tmp/etcd-download-test/etcdctl version

mv /tmp/etcd-download-test/etcdctl /usr/bin
```

# 2. Backup
minikube의 경우 /etc/kubernetes/mainifests/kube-apiserver.yaml 참조

```
ETCDCTL_API=3 etcdctl --endpoints=https://[127.0.0.1]:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /tmp/snapshot-pre-boot.db
```

# -----------------------------
# Disaster Happens
# -----------------------------

# 3. Restore ETCD Snapshot to a new folder

```
ETCDCTL_API=3 etcdctl --endpoints=https://[127.0.0.1]:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt \
--name=master \
--cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key \
--data-dir /var/lib/etcd-from-backup \
--initial-cluster=master=https://127.0.0.1:2380 \
--initial-cluster-token etcd-cluster-1 \
--initial-advertise-peer-urls=https://127.0.0.1:2380 \
snapshot restore /tmp/snapshot-pre-boot.db
```

# 4. Modify /etc/kubernetes/manifests/etcd.yaml

Update ETCD POD to use the new data directory and cluster token by modifying the pod definition file at `/etc/kubernetes/manifests/etcd.yaml`. When this file is updated, the ETCD pod is automatically re-created as thisis a static pod placed under the `/etc/kubernetes/manifests` directory.

Update --data-dir to use new target location

```
--data-dir=/var/lib/etcd-from-backup
```

Update new initial-cluster-token to specify new cluster

```
--initial-cluster-token=etcd-cluster-1
```

Update volumes and volume mounts to point to new path

```
volumeMounts:
- mountPath: /var/lib/etcd-from-backup
name: etcd-data
- mountPath: /etc/kubernetes/pki/etcd
name: etcd-certs
hostNetwork: true
priorityClassName: system-cluster-critical
volumes:
- hostPath:
path: /var/lib/etcd-from-backup
type: DirectoryOrCreate
name: etcd-data
- hostPath:
path: /etc/kubernetes/pki/etcd
type: DirectoryOrCreate
name: etcd-certs
```

> Note: You don't really need to update data directory and volumeMounts.mountPath path above. You could simply just update the hostPath.path in the volumes section to point to the new directory. But if you are not working with a kubeadm deployed cluster, then you might have to update the data directory. That's why I left it as is.

만약 pod로 구성되지 않았다면 snap save 후
ETCDCTL_API=3 etcdctl snapshot status snapshot.db


service kube-apiserver stop

모든 수정작업이 완료된후에는

systemctl daemon-reload
servicec etcd restart
service kube-apiserver start

'나는 노동자 > KUBERNETES' 카테고리의 다른 글

etcd 설치 - 간략문서  (0) 2019.09.19
Article on Setting up Basic Authentication  (0) 2019.05.27
cluster upgrade process  (0) 2019.05.22
OS Upgrade drain cordon uncordon  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21

1.11 에서 1.12로 업글
모든 업글은 마이너 한 단계씩 업글 해야함

— Master 에서
kubectl drain master —ignore-daemonsets

apt-get update && apt-get upgrade -y kubeadm=1.12.0-00

kubeadm upgrade apply v1.12.0

apt install kubelet=1.12.0-00

Kubectl uncordon master

—-Slave node upgrade

kubectl drain node01 —ignore-daemonsets
수동 pod가 있다면. —force 추가

ssh node01
apt-get update && apt-get upgrade -u kubeadm=1.12.0-00

apt install kubelet=1.12.0-00

exit

Master에서
kubeadm upgrade node cofnig —kubelet-version $(kubelet —version | cut -d ‘ ‘ -f 2)

kubectl get nodes
kubectl uncordon node01


혹 안되면 systemctl restart kubelet를 해보시길

'나는 노동자 > KUBERNETES' 카테고리의 다른 글

Article on Setting up Basic Authentication  (0) 2019.05.27
Backup and Restore  (0) 2019.05.23
OS Upgrade drain cordon uncordon  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21
kubernetes add nodes  (0) 2019.04.22

Slave가 5분동안 죽어있으면 다운으로 간주함
Pod가 다른 노드로 분산됨
시간 변경방법

kube-cotroller-manager —pod-eviction-timeout=5m0s

kubectl drain node-1

노드관리를 위해 지정된 노드에 있는 포드들을 다른곳으로 이동시키는 명령어다, 우선 새로운 포드가 노드에 스케줄링되어서 실행되지 않도록 설정한다. 그리고 나서 기존에 이 노드에서 실행중이던 포드들을 삭제한다. 이때 노드에 데몬셋으로 실행된 포드들이 있으면 drain 이 실패한다, 데몬셋으로 실핸된 포드들은 삭제해도 데몬셋이 즉시 다시 실행되기 때문이다. 그래서 데몬샛으로 실행된 포드들을 무시하고 진행하려면

—ignore—daemonsets=true 옵션을 주고 drain하면된다 컨트롤러를 통해서 실행되지 않은 포드만으로 실행된 포드들이 있으면 drain이 실해한다. 컨트롤러에 의해 관리되고 있는 포드들은 삭제가 되더라도 컨트롤러가 클러스트내 달른 노드에 다시 동일한 역화라ㅏ을 하는 포드를 실행하지만 포드만으로 실행된 포드들은 한번 삭제되면 그것으로 끝이기 때문에 중요한 역할을 하는 포드였다면 위험하기 때문에 drain이 진행되지 않고 실패단다. 이럴경우 강제로진행하려면 —force 옵션을 주고 실행하면 된다.

drain되어서 스케줄링이 되지 않고 있는 상태를 풀어주려면 uncordon명령을 사용하면된다,

kubectl uncordon node-1

kubectl cordon ndoe-2

cordon은 지정된 노드에 더 이상 포드들이 스케줄링 되어 실행되지 않도록 한다

kubectl get nodes를 해보면 status에 ready외에 scheduingDisabled이 추가된걸 확인할수 있다.

'나는 노동자 > KUBERNETES' 카테고리의 다른 글

Backup and Restore  (0) 2019.05.23
cluster upgrade process  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21
kubernetes add nodes  (0) 2019.04.22
Service - NodePort  (0) 2018.08.02






'나는 노동자 > KUBERNETES' 카테고리의 다른 글

cluster upgrade process  (0) 2019.05.22
OS Upgrade drain cordon uncordon  (0) 2019.05.22
kubernetes add nodes  (0) 2019.04.22
Service - NodePort  (0) 2018.08.02
minikube 간단 설치  (0) 2018.04.26

to join new nodes to existing cluster is
kubeadm token create —print-join-command

토큰 새로만들면 된다
기존에 붙어 있는 노드와 무관
그냥 위처럼 하면됨
네트워크는 초기에 데몬셋로 구현되어 있어(데몬셋이 아니면. 개별 설치를 해줘야한다)
자동 설치됨

'나는 노동자 > KUBERNETES' 카테고리의 다른 글

cluster upgrade process  (0) 2019.05.22
OS Upgrade drain cordon uncordon  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21
Service - NodePort  (0) 2018.08.02
minikube 간단 설치  (0) 2018.04.26




[root@hadoopm KUBE]# more deployment-definition2.yml

apiVersion: apps/v1beta1

kind: Deployment

metadata:

  name: myapp-deployment

  labels:

    app: myapp

    type: front-end

spec:

  template:

    metadata:

      name: myapp-pod

      labels:

        app: myapp


    spec:

      containers:

        - name: nginx-container

          image: dockertest2.io:12000/nginx:latest


  replicas: 3

  selector:

    matchLabels:

      app: myapp




Algorithm: Random

SessionAffinity: Yes


minikube일 경우 minikube ip를 통해 ip를 알아내고 

해당 ip:30008로 통신한다


연결이 안되면 service-definition.yml에서  type: front-end를 삭제해보자... pod쪽에서 찾지를 못해  조건에 맞는 pod를 못찾아서 생긴 문제







'나는 노동자 > KUBERNETES' 카테고리의 다른 글

cluster upgrade process  (0) 2019.05.22
OS Upgrade drain cordon uncordon  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21
kubernetes add nodes  (0) 2019.04.22
minikube 간단 설치  (0) 2018.04.26

설치를 하기전에 바이오스에

VT-x or AMD-v virtualization must be enabled in your computer’s BIOS.

그리고 

VirturlBox다운로드 경로

https://www.virtualbox.org/wiki/Download_Old_Builds_5_1

다운로드 후 실행


https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/windows/amd64/kubectl.exe

다운받아서 SYSTEM PATH에 경로는 적어준다.


[내컴퓨터] -[속성] - 설정변경 - 고급탭- 환경변수 - 시스템 변수 항목에서 Path라는것을 선택하고 편집 kubectl.exe경로를 넣어줌

세미콜론(;)이 구분자임



https://github.com/kubernetes/minikube/releases 

다운로드  minikube-installer.exe


cmd창에서

>minikube version


> mini kube start --vm-driver=hyperv --hyperv-virtual-switch="external"
  --kubernetes-version="v1.8.0" --memory=4096


이케하면 cluster를 다운로드함


아니면  minikube start --cpus 4 --memory 2048  이런식으로 해도 됨..


요케하며  VirtualBox관리자에 minikube라는 vm이 만들어지며 자동 실행되게 된다

가상(관리화면)머신을 선택하면 vm으로 넣어가며 minikube login: 이 라고 나온다.. root를 치면 암호를 묻지 않고 들어간다


윈도우화면에서(cmd)  minikube status   - 상태확인

minikube stop/start


minikube dashboard  이렇게하면   http://xx.xx.xx.xx:30000/#!/overview?namespace=default 라는 웹 브라우져가 뜸


명령어설명
minikube addons미니큐브의 쿠버네티스 애드온 변경
minikube cache로컬 캐시에서 이미지 추가/삭제
minikube completionOutputs minikube shell completion for the given shell (bash or zsh)
minikube config미니큐브 설정 변경
minikube dashboardOpens/displays the kubernetes dashboard URL for your local cluster
minikube delete로컬 쿠버네티스 클러스터 삭제
minikube docker-env도커 환경변수 설정하기. $(docker-machine env)와 유사함
minikube get-k8s-versions로컬큐브 부트스트래퍼를 사용할 때 미니큐브에 사용가능한 쿠버네티스 버전 목록 조회
minikube ip실행중인 클러스터의 IP 주소 조회
minikube logs실해중인 로컬큐브 인스턴스의 로그 조회. (사용자 코드가 아니라) 미니큐브 디버깅에 사용
minikube mount미니큐브에 특정 디렉토리 마운트
minikube profileProfile sets the current minikube profile
minikube serviceGets the kubernetes URL(s) for the specified service in your local cluster
minikube sshLog into or run a command on a machine with SSH; similar to 'docker-machine ssh'
minikube ssh-keyRetrieve the ssh identity key path of the specified cluster
minikube startStarts a local kubernetes cluster
minikube statusGets the status of a local kubernetes cluster
minikube stopStops a running local kubernetes cluster
minikube update-check현재 및 최신버전 출력
minikube update-contextVerify the IP address of the running cluster in kubeconfig.
minikube version미니큐브 버전 출력


'나는 노동자 > KUBERNETES' 카테고리의 다른 글

cluster upgrade process  (0) 2019.05.22
OS Upgrade drain cordon uncordon  (0) 2019.05.22
configmap,secret in pod  (0) 2019.05.21
kubernetes add nodes  (0) 2019.04.22
Service - NodePort  (0) 2018.08.02

+ Recent posts