반응형

컨테이너가 linux 의 cgroup 과 namespace 를 활용하여 동작하는 것은 이제 보편적으로 알려진 내용입니다. cgroup 은 자원의 활용에 사용하고 namespace 는 자원의 isolation 에 사용합니다.


이 중에서 namespace 의 종류는 다음과 같습니다.


ipc : 프로세스간 양방향 통신

mnt : 파일 시스템

net : 네트워크

pid : 프로세스 id

user : 사용자 계정

uts : Unix time sharing

 

위의 namespace를 기본으로 docker 의 프로세스 구조를 보면 다음과 같습니다.

먼저, pstree 명령어를 설치합니다.  어떤 패키지인지 모르면 아래 명령어로 패키지명을 찾을 수 있습니다.


$ sudo yum whatprovides pstree

psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system

Repo        : base

Matched from:

Filename    : /usr/bin/pstree

 

$ sudo yum install -y psmisc

 

이제 pstree 로 docker 의 패키지를 봅니다.


$ pstree -lSps $(pidof dockerd)




() 안에 들어간 번호는 프로세스 id 입니다.  dockerd 프로세스는 15472 이고 이후의 프로세스 명이 잘려서 보이니 ps 로 프로세스 명을 보면 다음과 같습니다.


$ ps -ef | grep 15489


15489 는 docker-containerd 입니다.

 

$ ps -ef | grep 15675



15675 는 docker-container-shim 입니다.


$ ps -ef | grep 15711


그리고 실제 컨테이너로 띄고 있는 minio 프로세스는 15711 입니다.



위의 내용을 보면 docker 프로세스는 다음과 같은 구조로 되어 있습니다.


dockerd (15472, docker 데몬)   ->   docker-containerd (15489, docker cotainerd) -> docker-container-shim (15675) -> minio (15711, 실행중인 docker 컨테이너)


docker-containerd 는 docker runtime 과 관련 있습니다. 컨테이너 실행은 runc 와 containerd 를 따릅니다. runc 는 Open Container Initiative(OCI) 에 의해 정의된 컨테이너를 실행시키는 부분으로 namespace 와 보안에 관한 표준입니다. containerd 는 runc 를 기반으로 컨테이너 이미지 관리, 스토리지, 실행 등의 기능을 확장한 것으로 CNCF 에 기부된 프로젝트 입니다.

 

docker-container-shim 은 docker 에서 자체적으로 추가한 것으로, 실행되는 컨테이너와 containerd 사이에서 컨테이너를 연결하여 containerd  가 문제가 생기더라도 실행되는 컨테이너에는 여향을 주지 않기 위해서 만들었습니다. 그런데 사실 이게 왜 더 필요한지는 모르겠습니다. 괜히 관리 레이어만 하나 더 추가된 부분으로 보이긴 합니다.

 

PID namespace 를 docker 에서 어떻게 적용되는지 보겠습니다.


앞에서 minio 컨테이너는 host 에서 보면 프로세스 id 가 15711 이고 그 부모 프로세스는 15675 인 docker-container-shim 인 것을 확인했습니다.


이제 minio 컨테이너를 아래와 같이 확인 합니다.


$ sudo docker (container) ls | grep minio

0b4bc5ba78f9        minio/minio                 "minio server /export"   18 months ago       Up 4 hours          0.0.0.0:9000->9000/tcp   minio

 

그리고, minio 컨테이너 안으로 들어가 보겠습니다.

sudo docker (container) exec -it 0b4bc5ba78f9 sh

 

프로세스를 조회해보면 다음과 같이 1번 프로세스로 minio 서버를 띄운 것이 보이고 (컨테이너 밖의 host 에서는 15711) 그 위의 부모 프로세스는 보이지 않습니다.




 

반응형
Posted by seungkyua@gmail.com
,
반응형

Kubernetes 는 여러 컨테이너를 관리할 수 있습니다. 그 이유는 kubernetes kubelet 과 컨테이너 데몬이 정해진 spec 에 따라 gRPC 통신을 하기 때문입니다.  Kubernetes 는 여러 컨테이너를 적용할 수 있는데 rkt, docker, CRI-O 등이 있습니다. 이중에서 가장 많이 사용하는 Docker 에 대해서 설명하고자 합니다.

앞서 kubespray 사용에 대해서 설명이 있는데, 여기를 보면 Production Level 로 사용 가능한 CentOS, RedHat, Ubuntu에 맞게 docker 를 쉽게 설치할 수 있습니다. 여기서는 Docker 를 이미 설치한 후에 어떻게 Docker 를 잘 활용할 수 있는지에 대해서 설명합니다.

1. dockerd config option reload

대부분의 Linux 는 이제 systemd 를 활용하고 있습니다. 그렇기 때문에 docker 데몬 실행은 systemd 에 설치된 docker.service 를 보면 됩니다. 디렉토리는 둘 중에 하나를 찾아보면 됩니다.

/etc/systemd/system/multi-user.target.wants/docker.service

/etc/systemd/system/docker.service

 

제 환경은 CentOS 로 이렇게 정의가 되어 있습니다.

MountFlags=shared

EnvironmentFile=-/etc/sysconfig/docker

ExecStart=/usr/bin/dockerd $DOCKER_OPTS

ExecReload=/bin/kill -s HUP $MAINPID

 

dockerd 의 환경 파일로 /etc/sysconfig/docker 를 읽게 되어 있고 해당 파일은 아래 옵션으로 정의되어 있습니다.

DOCKER_OPTS="--storage-driver=overlay2 --insecure-registry docker-registry:5000 --insecure-registry oreo:5000"

 

이 경우 systemctl restart docker.service 를 하면 dockerd 가 restart 되는데 문제는 이미 실행되고 있는 docker 컨테이너가 영향을 받아 stop 으로 빠집니다. (kubernetes 의 deployment, daemonset, statefulset 혹은 docker 의 --restart=always 가 아닌 경우) 그러므로, docker 옵션만 reload 해야 기존의 실행되고 있는 컨테이너가 영향을 받지 않습니다.

docker option reload 는 SIGHUP 을 보내면 됩니다. 

$ sudo kill -SIGHUP $(pidof dockerd)

 

하지만, 지금의 세팅으로는 다시 올라오지 않습니다.

dockerd 로그를 보면 다음과 같습니다. 로그는 다음 명령어로 볼 수 있습니다.

$ sudo journalctl --no-pager -u docker.service

kube-deploy dockerd[16391]: time="2018-10-27T18:36:17.767207453+09:00" level=info msg="Got signal to reload configuration, reloading from: /etc/docker/daemon.json"

kube-deploy dockerd[16391]: time="2018-10-27T18:36:17.767283042+09:00" level=error msg="open /etc/docker/daemon.json: no such file or directory"

 

디폴트로 dockerd 옵션은 /etc/docker/daemon.json 파일을 읽기 때문에 옵션  reload  가 안되는 문제가 있습니다.

이를 해결하기 위해서 다음과 같이 변경해 보겠습니다.

docker.service 에 정의된 EnvironmentFile 의 변수를 daemon.json 으로 옮기겠습니다.

/etc/systemd/system/multi-user.target.wants/docker.service

EnvironmentFile=-

 

$ sudo mkdir -p /etc/docker

$ sudo vi /etc/docker/daemon.json

{

    "storage-driver": "overlay2",

    "insecure-registries": ["docker-registry:5000", "oreo:5000"]

}

 

docker.service 를 바꿨으니 어쩔 수 없이 한 번의 docker restart 는 해야 합니다.

$ sudo systemctl daemon-reload

$ systemctl restart docker.service

 

이제 현재의 dockerd option 이 어떤지 보겠습니다.

$ sudo docker system info

 

Storage Driver: overlay2

Insecure Registries:

  docker-registry:5000

  oreo:5000

  127.0.0.0/8

 

Insecure Registries 의 oreo:5000 을 제거하고 싶다면 다음과 같이 daemon.json 에서 변경하면 됩니다.

{

    "storage-driver": "overlay2",

    "insecure-registries": ["docker-registry:5000"]

}

 

그리고 SIGHUP 을 보내서 option reload 를 하면 새로운 옵션이 적용됩니다.

$ sudo kill -SIGHUP $(pidof dockerd)

 

dockerd 옵션에 oreo:5000 이 Insecure Registries 에서 빠져 있는 것을 볼 수 있습니다.

$ sudo docker system info

 

Storage Driver: overlay2

Insecure Registries:

  docker-registry:5000

  127.0.0.0/8

 

 

반응형
Posted by seungkyua@gmail.com
,
반응형

일반적으로 RBAC 으로 Kubernetes Dashboard 를 설치하면 service account 의 token 을 가지고 접속해야 합니다.


admin clusterrole 을 가진 secret 을 찾아서 해당 token 으로 접속합니다.

$ kubectl -n kube-system describe secret clusterrole-aggregation-controller-token-fmnfg


Name:         clusterrole-aggregation-controller-token-fmnfg

Namespace:    kube-system

Labels:       <none>

Annotations:  kubernetes.io/service-account.name=clusterrole-aggregation-controller

              kubernetes.io/service-account.uid=ccbaf065-8f01-11e8-80c8-3ca82a1ccfd4


Type:  kubernetes.io/service-account-token


Data

====

ca.crt:     1025 bytes

namespace:  11 bytes

token:      xxxxxxxxxxxxxxxxxxxxxxxxxxxx


매번 이런 token 방식이 귀찮으면 아래와 같이 dashboard service account 에 admin clusterrole 을 지정하고 로그인 화면에서는 skip 을 클릭하여 넘어가면 됩니다.

$ kubectl get serviceaccount -n kube-system | grep kubernetes-dashboard

kubernetes-dashboard                 1         8d 


$ kubectl create clusterrolebinding kubernetes-dashboard-admin \

--clusterrole=cluster-admin \

--serviceaccount=kube-system:kubernetes-dashboard





반응형
Posted by seungkyua@gmail.com
,
반응형


Kubernetes dashboard 를 Ingress Controller 와 연결할 때 SSL 을 적용하고 싶으면 다음과 같이 Ingress 를 생성하면 된다.



Kubernetes dashboard ingress 


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/secure-backends: "true"
ingress.kubernetes.io/ssl-passthrough: "true"
nginx.org/ssl-backend: "kubernetes-dashboard"
kubernetes.io/ingress.allow-http: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/proxy-body-size: "100M"
name: kubernetes-dashboard
namespace: kube-system
spec:
tls:
- secretName: kubernetes-dashboard-certs
rules:
- host: dashboard.k8s.stage
http:
paths:
- path: /
backend:
serviceName: kubernetes-dashboard
servicePort: 443



반응형
Posted by seungkyua@gmail.com
,
반응형

Kubernetes pause infra container 는 기존의 golang 에서 c 로 변경되었다.


main 함수를 보면 다음과 같다.

int main(int argc, char **argv) {
int i;
for (i = 1; i < argc; ++i) {
if (!strcasecmp(argv[i], "-v")) {
printf("pause.c %s\n", VERSION_STRING(VERSION));
return 0;
}
}

if (getpid() != 1)
/* Not an error because pause sees use outside of infra containers. */
fprintf(stderr, "Warning: pause should be the first process\n");

if (sigaction(SIGINT, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0)
return 1;
if (sigaction(SIGTERM, &(struct sigaction){.sa_handler = sigdown}, NULL) < 0)
return 2;
if (sigaction(SIGCHLD, &(struct sigaction){.sa_handler = sigreap,
.sa_flags = SA_NOCLDSTOP},
NULL) < 0)
return 3;

for (;;)
pause();
fprintf(stderr, "Error: infinite loop terminated\n");
return 42;
}


pause 는 infra container 이므로 getpid() 가 1 인 최상의 프로세스가 되는 것이 Security 측면에서 바람직하다.


sigaction 은 signal 이 SIGINT (키보드 ctrl + c 로 종료), SIGTERM (종료) 가 들어오면 sigdown 함수를 handler 로 등록해서 수행한다.

자식 프로세스가 종료되거나 정지/재시작 될 때 SIGCHLD signal 이 발생하는데, SA_NOCLDSTOP flag 는 자식 프로세스가 정지되는 4가지의 signal - SIGSTOP(프로세스 정지), SIGTSTP(키보드 ctrl + z 로 발생한 프로세스 정지), SIGTTIN(백그라운드에서 제어터미널 읽기를 시도해서 정지), SIGTTOU(백그라운드에서 제어터미널 쓰기를 시도해서 정지) 등을 받아서 정지되거나 CONTINUE signal 을 받아서 재시작되어도 이를 통지 받지 않겠다는 의미이다. 즉, pause 가 부모 프로세스가 이지만 SIGCHLD signal 을 통보받을 필요가 없다고 생각하는 것이다.  하지만 그 나머지인 경우인 자식 프로세스가 종료되는 경우에는 signal 을 받을 수 밖에 없다. 이 때는 waitpid 함수를 통해서 혹시라도 자식 프로세스가 좀비가 되었을 때 좀비 프로세스를 제거할 수 있다.


sigaction 함수는 에러가 발생하면 -1 을 정상 처리되면 0을 리턴한다.


static void sigdown(int signo) {
psignal(signo, "Shutting down, got signal");
exit(0);
}

psignal 함수는 두번째 인자로 들어온 string 을 stderr 로 출력한다.



static void sigreap(int signo) {
while (waitpid(-1, NULL, WNOHANG) > 0)
;
}

자식 프로세스가 왜 종료 되었는지는 관심이 없고 단순히 자식 프로세스가 종료될 때 좀비 프로세스를 막고자 한다면 waitpid 함수를 위와 같이 사용한다.


첫번재 인자로 전달된 pid 값이 -1 이면 모든 자식 프로세스가 종료될 때 까지 기다린다. 하지만 마지막 인자로 WNOHANG 이 입력되면 부모 프로세스는 기다리지 않고 바로 리턴된다. 하나의 SIGCHLD 에 대해서 while 문으로 처리한 이유는 여러 자식 프로세스가 종료될 수 있는 가능성이 있기 때문이다. 즉, SIGCHLD signal 이전에 좀비 프로세스가 있으면 그것을 처리한다. 


그럼 결과적으로는 SIGCHLD signal 이 발생할 때 pause 프로세스는 아무것도 기다리지 않고 좀비 프로세스가 있으면 처리하고 바로 리턴한다.

그리고 마지막에 pause() 함수에 의해서 잠시 정지 상태가 된다. 



* 좀비 프로세스 : 자식 프로세스가 종료되어 사용하는 리소스는 모두 해제된 상태지만, 부모 프로세스가 자식 프로세스의 종료를 확인하지 못한 상태로 커널의 프로세스 테이블에는 관리되고 있는 상태

* 고아 프로세스 : 자식 프로세스 보다 부모 프로세스가 죽었을 경우 자식 프로세스가 pid 1 인 init 프로세스에 속하게 된 경우




 



 
















반응형
Posted by seungkyua@gmail.com
,
반응형

전쳬 에제 소스

https://github.com/seungkyua/hello-go


Go 프로그램에서 channel 을 사용할 때 가장 중요한 부분은 channel 을 한 번만 닫아야 한다는 것이다. 그렇지 않고 닫힌 channel 을 중복해서 닫으려고 하면 panic 이 발생한다. 그래서 Discovery Go 책에서는 channel 에 값을 보내는 쪽에서 닫는 패턴을 추천한다.


프로젝트로 완성하는 Go 프로그래밍(Go Programming Blueprints Second Edition) 의 chat 예제를 보면 client 가 종료되어도 client 가 가지고 있는 채널을 닫지 않는 에러가 있어 이를 간단히 수정했다.


client.go 의 client struct 에 필요없는 room 변수는 삭제했다. (나중에 필요하면 추가할지도)

대신 read 메소드에 root 의 forward channel 을 인자로 받는다. 

type client struct {
socket *websocket.Conn
send chan []byte
}


read 메소드에는 socket close 하는 부분이 있는데 socket 에러가 나면 read 가 에러가 날 것이고 이 때 defer 로 channel 닫는 부분을 추가한다. write 메소드에는 중복을 피하기 위해서 channel 닫는 부분을 넣지 않았다.


func (c *client) read(forward chan<- []byte) {
defer func() {
c.socket.Close()
log.Println("Client socker read closed.")
close(c.send)
log.Println("Client send channel closed.")
}()
for {
_, msg, err := c.socket.ReadMessage()
if err != nil {
log.Println("Client Socket ReadMaessage error")
return
}
forward <- msg
}
}

 

 root.go 에서는 쓰이고 있지는 않지만 client 에 leave 할 경우 기존 client channel 닫는 소스 대신 client socket 을 닫는 부분으로 변경했다. range 로 모든 client channel 에 값을 보내고 있기 때문에 여기는 보내는 channel 이지만 channel 을 닫기가 어렵다. 그래서 client 에서 channel 을 닫는 로직을 추가했다.

 

root struct 에서 생성한 forward, join, leave channel 은 처리하지 않았다. 나중에 room 에 client 가 아무도 없을 때의 로직에 추가되면 그 때 닫는 부분을 추가해야 한다.


func (r *room) run() {
go func() {
for {
select {
case client := <-r.join:
r.clients[client] = true
case client := <-r.leave:
delete(r.clients, client)
client.socket.Close()
case msg := <-r.forward:
for client := range r.clients {
client.send <- msg
}
}
}
}()
}








반응형
Posted by seungkyua@gmail.com
,
반응형


2018년 3월 26일 CNC & Kubernetes Meetup 발표 자료


 facebook group : https://www.facebook.com/groups/k8skr/


• 일시: 2018년 3월 26일(월) 오후 7시 30분 - 9시 30분

• 장소: 역삼역 7번 출구 GS타워 12층 AWS코리아 (강남구 논현로 508)

• 세션 내용:


19:30-20:10 Kubernetes 를 이용한 Cloud native platform 개발 (어형부형)



20:10-20:50 Helm chart 를 활용한 App 배포 방법 (안승규)








반응형
Posted by seungkyua@gmail.com
,

Helm chart

OpenStack 2018. 3. 23. 10:33
반응형



# ingress.yaml 


images:

      tags:

        entrypoint: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        ingress: registry.cicd.stg.taco/nginx-ingress-controller:0.9.0

        error_pages: registry.cicd.stg.taco/defaultbackend:1.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

      pull_policy: Always

    config:

      worker-processes: "8"

    pod:

      replicas:

        ingress: 1

        error_page: 1




# openstack-ceph-config.yaml


images:

      tags:

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ceph_bootstrap: registry.cicd.stg.taco/ceph-daemon:tag-build-master-jewel-ubuntu-16.04

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        ceph_daemon: registry.cicd.stg.taco/ceph-daemon:tag-build-master-jewel-ubuntu-16.04

        ceph_config_helper: registry.cicd.stg.taco/ceph-config-helper:v1.7.5

        ceph_rbd_provisioner: registry.cicd.stg.taco/rbd-provisioner:v0.1.1

        ceph_cephfs_provisioner: registry.cicd.stg.taco/cephfs-provisioner:v0.1.1

      pull_policy: IfNotPresent 

    deployment:

      storage_secrets: true

      client_secrets: true

      rbd_provisioner: false

      cephfs_provisioner: false

      rgw_keystone_user_and_endpoints: false

    conf:

      ceph:

        global:

          mon_host: 192.168.51.20

    storageclass:

      rbd:

        provision_storage_class: false

        user_id: cinder

        admin_secret_namespace: openstack

      cephfs:

        provision_storage_class: false

        dmin_secret_namespace: openstack

    manifests:

      configmap_bin_clients: true

      configmap_bin_ks: true

      configmap_bin: true

      configmap_etc: true

      configmap_templates: true

      daemonset_mon: false

      daemonset_osd: false

      deployment_mds: false

      deployment_moncheck: false

      deployment_rbd_provisioner: false

      deployment_cephfs_provisioner: false

      deployment_rgw: false

      deployment_mgr: false

      job_bootstrap: false

      job_cephfs_client_key: false

      job_keyring: false

      job_ks_endpoints: false

      job_ks_service: false

      job_ks_user: false

      job_namespace_client_key_cleaner: true

      job_namespace_client_key: true

      job_rbd_pool: false

      job_storage_admin_keys: true

      secret_keystone_rgw: false

      secret_keystone: false

      service_mgr: false

      service_mon: false

      service_rgw: false

      service_mon_discovery: false

      storageclass: false

    dependencies:

      rbd_provisioner:

        jobs:

        services:




# mariadb.yaml


images:

      tags:

        mariadb: registry.cicd.stg.taco/mariadb:10.1.23

        test: registry.cicd.stg.taco/ocata/ubuntu-source-kolla-toolbox:develop

      pull_policy: Always

    pod:

      replicas:

        server: 3

    volume:

      enabled: true

      class_name: ceph



# etcd.yaml


images:

      tags:

        etcd: registry.cicd.stg.taco/etcd:v3.2.5 

        test: registry.cicd.stg.taco/ocata/ubuntu-source-kolla-toolbox:develop

      pull_policy: IfNotPresent

    pod:

      replicas:

        etcd: 1



# rabbitmq.yaml


images:

      tags:

        rabbitmq: registry.cicd.stg.taco/rabbitmq:3.7

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        test: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

      pull_policy: IfNotPresent

    pod:

      replicas:

        server: 3

    volume:

      class_name: ceph




# memcached.yaml


images:

      tags:

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        memcached: registry.cicd.stg.taco/memcached:1.5.5 

      pull_policy: IfNotPresent

    pod:

      replicas:

        server: 1





# libvirt.yaml


images:

      tags:

        libvirt: registry.cicd.stg.taco/ocata/ubuntu-source-nova-libvirt:2.2.0

      pull_policy: Always

    ceph:

      enabled: true

      cinder_user: "cinder"

      cinder_keyring: "xxxxx=="

    libvirt:

      listen_addr: 0.0.0.0

      log_level: 3

    manifests:

      configmap_bin: true

      configmap_etc: true

      daemonset_libvirt: true




# openvswitch.yaml


images:

      tags:

        openvswitch_db_server: registry.cicd.stg.taco/ocata/ubuntu-source-openvswitch-db-server:2.2.0

        openvswitch_vswitchd: registry.cicd.stg.taco/ocata/ubuntu-source-openvswitch-vswitchd:2.2.0

      pull_policy: Always

    network:

      external_bridge: br-ex

      interface:

        external: bond1.52

      auto_bridge_add: {}




# keystone.yaml


images:

      tags:

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        test: registry.cicd.stg.taco/ocata/ubuntu-source-rally:2.2.0

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        keystone_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        keystone_fernet_setup: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        keystone_fernet_rotate: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        keystone_credential_setup: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        keystone_credential_rotate: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        keystone_api: registry.cicd.stg.taco/ocata/ubuntu-source-keystone:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

      pull_policy: Always

    conf:

      keystone:

        DEFAULT:

          debug: true

    pod:

      replicas:

        api: 3




# glance.yaml


storage: rbd

    images:

      tags:

        test: registry.cicd.stg.taco/ocata/ubuntu-source-rally:2.2.0

        glance_storage_init: registry.cicd.stg.taco/ceph-daemon:tag-build-master-jewel-ubuntu-16.04

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        glance_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-glance-api:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        glance_api: registry.cicd.stg.taco/ocata/ubuntu-source-glance-api:2.2.0

        glance_registry: registry.cicd.stg.taco/ocata/ubuntu-source-glance-registry:2.2.0

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

      pull_policy: Always

    pod:

      replicas:

        api: 3

        registry: 3

      user:

        glance:

          uid: 42415

    network:

      api:

        ingress:

          proxy_body_size: 102400M

    conf:

      ceph:

        monitors: ["192.168.51.20"]

        admin_keyring: "xxxx=="

      glance:

        glance_store:

          rbd_store_user: glance

          rbd_store_pool: images

        DEFAULT:

          show_image_direct_url: true

    bootstrap:

      enabled: true

      images:

        cirros:

          id: 201084fc-c276-4744-8504-cb974dbb3610

          private: false




# nova.yaml


images:

      tags:

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-kolla-toolbox:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-kolla-toolbox:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-kolla-toolbox:2.2.0

        nova_api: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        nova_cell_setup: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        nova_compute: registry.cicd.stg.taco/ocata/ubuntu-source-nova-compute:2.2.0

        nova_compute_ironic: registry.cicd.stg.taco/ocata/ubuntu-source-nova-compute-ironic:2.2.0

        nova_compute_ssh: registry.cicd.stg.taco/ocata/ubuntu-source-nova-ssh:2.2.0

        nova_conductor: registry.cicd.stg.taco/ocata/ubuntu-source-nova-conductor:2.2.0

        nova_consoleauth: registry.cicd.stg.taco/ocata/ubuntu-source-nova-consoleauth:2.2.0

        nova_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-nova-api:2.2.0

        nova_novncproxy: registry.cicd.stg.taco/ocata/ubuntu-source-nova-novncproxy:2.2.0

        nova_novncproxy_assets: registry.cicd.stg.taco/ocata/ubuntu-source-nova-novncproxy:2.2.0

        nova_placement: registry.cicd.stg.taco/ocata/ubuntu-source-nova-placement-api:2.2.0

        nova_scheduler: registry.cicd.stg.taco/ocata/ubuntu-source-nova-scheduler:2.2.0

        nova_spiceproxy: registry.cicd.stg.taco/ocata/ubuntu-source-nova-spicehtml5proxy:2.2.0

        nova_spiceproxy_assets: registry.cicd.stg.taco/ocata/ubuntu-source-nova-spicehtml5proxy:2.2.0

        test: registry.cicd.stg.taco/ocata/ubuntu-source-rally:2.2.0

      pull_policy: Always

    bootstrap:

      enabled: true

      flavors:

        m1_tiny:

          id: 0c84e220-a258-439f-a6ff-f8e9fd980025

    network:

      novncproxy:

        name: "nova-novncproxy"

        node_port:

          enabled: true

          port: 30608

        port: 6080

        targetPort: 6080

    ceph:

      enabled: true

      cinder_user: "cinder"

      cinder_keyring: "xxxx=="

      secret_uuid: "582393ff-9a5c-4a2e-ae0d-86ec18c36afc"

    conf:

      nova:

        DEFAULT:

          force_config_drive: true

          scheduler_default_filters: "RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter"

          debug: true

        vnc:

          novncproxy_base_url: http://ctrl01-stg:30608/vnc_auto.html

        libvirt:

          rbd_user: "cinder"

          rbd_secret_uuid: "582393ff-9a5c-4a2e-ae0d-86ec18c36afc"

        scheduler:

          discover_hosts_in_cells_interval: 60

    endpoints:

      oslo_db_cell0:

        path: /nova_cell0

    pod:

      user:

        nova:

          uid: 42436

      replicas:

        api_metadata: 3

        osapi: 3

        conductor: 3

        consoleauth: 3

        scheduler: 3

        novncproxy: 3




# neutron.yaml


images:

      tags:

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        neutron_test: registry.cicd.stg.taco/ocata/ubuntu-source-rally:2.2.0

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        neutron_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-server:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        neutron_server: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-server:2.2.0

        neutron_dhcp: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-dhcp-agent:2.2.0

        neutron_metadata: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-metadata-agent:2.2.0

        neutron_l3: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-l3-agent:2.2.0

        neutron_openvswitch_agent: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-openvswitch-agent:2.2.0

        neutron_linuxbridge_agent: registry.cicd.stg.taco/ocata/ubuntu-source-neutron-linuxbridge-agent:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

      pull_policy: Always

    pod:

      replicas:

        server: 3

      user:

        neutron:

          uid: 42435

    labels:

      agent:

        dhcp:

          node_selector_key: openstack-network-node

        l3:

          node_selector_key: openstack-network-node

    manifests:

      daemonset_metadata_agent: false

      daemonset_ovs_agent: true

      daemonset_lb_agent: false

    network:

      backend: ovs

      external_bridge: br-ex

      interface:

        tunnel: bond1

    conf:

      neutron_sudoers:

        override: |

          # This sudoers file supports rootwrap-daemon for both Kolla and LOCI Images.

          Defaults !requiretty

          Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/var/lib/openstack/bin:/var/lib/kolla/venv/bin"

          neutron ALL = (root) NOPASSWD: /var/lib/kolla/venv/bin/neutron-rootwrap /etc/neutron/rootwrap.conf *, /var/lib/openstack/bin/neutron-rootwrap /etc/neutron/rootwrap.conf *, /var/lib/kolla/venv/bin/neutron-rootwrap-daemon /etc/neutron/rootwrap.conf, /var/lib/openstack/bin/neutron-rootwrap-daemon /etc/neutron/rootwrap.conf

      neutron:

        DEFAULT:

          debug: True

          core_plugin: ml2

          l3_ha: True

          global_physnet_mtu: 9000

          service_plugins: router

          interface_driver: openvswitch

        agent:

          root_helper_daemon: sudo neutron-rootwrap-daemon /etc/neutron/rootwrap.conf

      plugins:

        ml2_conf:

          ml2:

            mechanism_drivers: openvswitch,l2population

            type_drivers: flat, vlan, vxlan

            tenant_network_types: vxlan

        openvswitch_agent:

          agent:

            tunnel_types: vxlan

            l2_population: True

            arp_responder: True

          ovs:

            bridge_mappings: "external:br-ex"

          securitygroup:

            firewall_driver: openvswitch






# cinder.yaml


images:

      tags:

        test: registry.cicd.stg.taco/ocata/ubuntu-source-rally:2.2.0

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        cinder_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-api:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        cinder_api: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-api:2.2.0

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        cinder_scheduler: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-scheduler:2.2.0

        cinder_volume: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-volume:2.2.0

        cinder_volume_usage_audit: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-volume:2.2.0

        cinder_storage_init: registry.cicd.stg.taco/ceph-daemon:tag-build-master-jewel-ubuntu-16.04

        cinder_backup: registry.cicd.stg.taco/ocata/ubuntu-source-cinder-backup:2.2.0

        cinder_backup_storage_init: registry.cicd.stg.taco/ceph-daemon:tag-build-master-jewel-ubuntu-16.04

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

      pull_policy: Always

    pod:

      user:

        cinder:

          uid: 42407

      replicas:

        api: 3

        backup: 1

        scheduler: 3

        volume: 1

    conf:

      ceph:

        admin_keyring: "xxxxx=="

        monitors: ["192.168.51.20"]

      cinder:

        DEFAULT:

          debug: true

          backup_ceph_user: "cinder"

          backup_ceph_pool: "backups"

      backends:

        rbd1:

          volume_driver: cinder.volume.drivers.rbd.RBDDriver

          volume_backend_name: rbd1

          rbd_ceph_conf: "/etc/ceph/ceph.conf"

          rbd_flatten_volume_from_snapshot: false

          rbd_max_clone_depth: 5

          rbd_store_chunk_size: 4

          rados_connect_timeout: -1

          rbd_user: "cinder"

          rbd_pool: "volumes"





# heat.yaml


images:

      tags:

        bootstrap: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        heat_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-heat-api:2.2.0

        db_drop: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_user: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_service: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        ks_endpoints: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        heat_api: registry.cicd.stg.taco/ocata/ubuntu-source-heat-api:2.2.0

        heat_cfn: registry.cicd.stg.taco/ocata/ubuntu-source-heat-api:2.2.0

        heat_cloudwatch: registry.cicd.stg.taco/ocata/ubuntu-source-heat-api:2.2.0

        heat_engine: registry.cicd.stg.taco/ocata/ubuntu-source-heat-engine:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        rabbit_init: registry.cicd.stg.taco/rabbitmq:3.7-management

      pull_policy: Always

    pod:

      user:

        heat:

          uid: 42418

      replicas:

        api: 3

        cfn: 3

        cloudwatch: 3

        engine: 3



# horizon.yaml


images:

      tags:

        db_init: registry.cicd.stg.taco/ocata/ubuntu-source-horizon:2.2.0

        horizon_db_sync: registry.cicd.stg.taco/ocata/ubuntu-source-horizon:2.2.0

        horizon: registry.cicd.stg.taco/ocata/ubuntu-source-horizon:2.2.0

        dep_check: registry.cicd.stg.taco/kubernetes-entrypoint:v0.2.1

        test: registry.cicd.stg.taco/ocata/ubuntu-source-horizon:develop

      pull_policy: Always

    pod:

      replicas:

        server: 3

    network:

      external_policy_local: false

      node_port:

        enabled: true

        port: 32000

    local_settings:

      openstack_neutron_network:

        enable_router: "True"

        enable_quotas: "True"

        enable_ipv6: "False"

        enable_distributed_router: "False"

        enable_ha_router: "True"

        enable_lb: "True"

        enable_firewall: "False"

        enable_vpn: "False"

        enable_fip_topology_check: "True"




반응형
Posted by seungkyua@gmail.com
,
반응형

OpenStack 발표자료 (From Kubernetes to OpenStack)





반응형
Posted by seungkyua@gmail.com
,

mariadb with galera setting

MySQL 2017. 11. 24. 16:41
반응형
## /etc/mysql/my.cnf 설정 파일

[mysqld]
# base directory
datadir=/var/lib/mysql
tmpdir=/tmp

# Charset
character_set_server=utf8
collation_server=utf8_unicode_ci
skip-character-set-client-handshake

# Logging
slow_query_log=on
slow_query_log_file=/var/log/mysql/mariadb-slow.log
log_warnings=2

# General logging has huge performance penalty therefore is disabled by default
general_log=off
general_log_file=/var/log/mysql/mariadb-error.log

long_query_time=3
log_queries_not_using_indexes=on

# Networking
bind_address=0.0.0.0
port=3306

# When a client connects, the server will perform hostname resolution,
# and when DNS is slow, establishing the connection will become slow as well.
# It is therefore recommended to start the server with skip-name-resolve to
# disable all DNS lookups. The only limitation is that the GRANT statements
# must then use IP addresses only.
skip_name_resolve

# Tuning
user=mysql
max_allowed_packet=256M
open_files_limit=10240
max_connections=8192
max-connect-errors=1000000
join_buffer_size = 192K
tmp_table_size = 16M
max_heap_table_size = 16M

## Generally, it is unwise to set the query cache to be larger than 64-128M
## as the costs associated with maintaining the cache outweigh the performance
## gains.
## The query cache is a well known bottleneck that can be seen even when
## concurrency is moderate. The best option is to disable it from day 1
## by setting query_cache_size=0 (now the default on MySQL 5.6)
## and to use other ways to speed up read queries: good indexing, adding
## replicas to spread the read load or using an external cache.
query_cache_size=0
query_cache_type=0

sync_binlog=0
thread_cache_size=16
table_open_cache=2048
table_definition_cache=1024

#
# InnoDB
#
# The buffer pool is where data and indexes are cached: having it as large as possible
# will ensure you use memory and not disks for most read operations.
# Typical values are 50..75% of available RAM.
# TODO(tomasz.paszkowski): This needs to by dynamic based on available RAM.
innodb_buffer_pool_size=10G
innodb_log_file_size=128M
innodb_file_per_table=1
innodb_doublewrite=0
innodb_file_format=Barracuda
innodb_flush_method=O_DIRECT
innodb_io_capacity=500
innodb_old_blocks_time=1000
innodb_read_io_threads=8
innodb_write_io_threads=8

# Clustering
binlog_format=ROW
default-storage-engine=InnoDB
innodb_autoinc_lock_mode=2
innodb_flush_log_at_trx_commit=2
innodb_locks_unsafe_for_binlog=1
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_name=mariadb
wsrep_node_name=mariadb-0.mariadb-discovery
wsrep_node_address=172.16.10.252
wsrep_cluster_address="gcomm://mariadb-1.mariadb-discovery:4567,mariadb-2.mariadb-discovery:4567"
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=root:password
wsrep_provider_options="gcache.size=512M; gcache.name=/tmp/galera.cache; gcache.page_size=128M; gmcast.listen_addr=tcp://0.0.0.0:4567"
wsrep_slave_threads=16
wsrep_on=1

[mysqldump]
max-allowed-packet=16M

[client]
default_character_set=utf8
protocol=tcp
port=3306
connect_timeout=10




## sync 상태 보기 (각 mariadb 서버에서)
MariaDB [(none)]> show status like 'wsrep_%';
+------------------------------+-------------------------------------------------------------+
| Variable_name                | Value                                                       |
+------------------------------+-------------------------------------------------------------+
| wsrep_apply_oooe             | 0.007694                                                    |
| wsrep_apply_oool             | 0.000000                                                    |
| wsrep_apply_window           | 1.014445                                                    |
| wsrep_causal_reads           | 0                                                           |
| wsrep_cert_deps_distance     | 25.653383                                                   |
| wsrep_cert_index_size        | 67                                                          |
| wsrep_cert_interval          | 0.007814                                                    |
| wsrep_cluster_conf_id        | 3                                                           |
| wsrep_cluster_size           | 3                                                           |
| wsrep_cluster_state_uuid     | 86cf6166-d00b-11e7-92f6-bf254b8a19b3                        |
| wsrep_cluster_status         | Primary                                                     |
| wsrep_commit_oooe            | 0.000000                                                    |
| wsrep_commit_oool            | 0.000000                                                    |
| wsrep_commit_window          | 1.006594                                                    |
| wsrep_connected              | ON                                                          |
| wsrep_desync_count           | 0                                                           |
| wsrep_evs_delayed            |                                                             |
| wsrep_evs_evict_list         |                                                             |
| wsrep_evs_repl_latency       | 0.000495221/0.000788639/0.00164732/0.00034555/19            |
| wsrep_evs_state              | OPERATIONAL                                                 |
| wsrep_flow_control_paused    | 0.000000                                                    |
| wsrep_flow_control_paused_ns | 0                                                           |
| wsrep_flow_control_recv      | 0                                                           |
| wsrep_flow_control_sent      | 0                                                           |
| wsrep_gcomm_uuid             | f14761b1-d026-11e7-a9c6-43e9a12bd841                        |
| wsrep_incoming_addresses     | 192.168.236.97:3306,192.168.28.197:3306,192.168.105.20:3306 |
| wsrep_last_committed         | 12525                                                       |
| wsrep_local_bf_aborts        | 0                                                           |
| wsrep_local_cached_downto    | 6127                                                        |
| wsrep_local_cert_failures    | 0                                                           |
| wsrep_local_commits          | 970                                                         |
| wsrep_local_index            | 2                                                           |
| wsrep_local_recv_queue       | 0                                                           |
| wsrep_local_recv_queue_avg   | 0.143574                                                    |
| wsrep_local_recv_queue_max   | 40                                                          |
| wsrep_local_recv_queue_min   | 0                                                           |
| wsrep_local_replays          | 0                                                           |
| wsrep_local_send_queue       | 0                                                           |
| wsrep_local_send_queue_avg   | 0.000978                                                    |
| wsrep_local_send_queue_max   | 2                                                           |
| wsrep_local_send_queue_min   | 0                                                           |
| wsrep_local_state            | 4                                                           |
| wsrep_local_state_comment    | Synced                                                      |
| wsrep_local_state_uuid       | 86cf6166-d00b-11e7-92f6-bf254b8a19b3                        |
| wsrep_protocol_version       | 7                                                           |
| wsrep_provider_name          | Galera                                                      |
| wsrep_provider_vendor        | Codership Oy <info@codership.com>                           |
| wsrep_provider_version       | 25.3.20(r3703)                                              |
| wsrep_ready                  | ON                                                          |
| wsrep_received               | 5579                                                        |
| wsrep_received_bytes         | 4241688                                                     |
| wsrep_repl_data_bytes        | 441822                                                      |
| wsrep_repl_keys              | 4283                                                        |
| wsrep_repl_keys_bytes        | 56574                                                       |
| wsrep_repl_other_bytes       | 0                                                           |
| wsrep_replicated             | 970                                                         |
| wsrep_replicated_bytes       | 560476                                                      |
| wsrep_thread_count           | 13                                                          |

+------------------------------+-------------------------------------------------------------+ 


wsrep_cluster_conf_id : 모든 db 에 똑같은 id 로 설정되어야 함

wsrep_cluster_size : 클러스터의 노드 갯수

wsrep_cluster_state_uuid : 고유 클러스터 ID 로 클러스터의 노드는 같은 값을 가져야 함

wsrep_cluster_status : 노드의 역할

wsrep_incoming_addresses : 클러스터 멤버의 ip 

wsrep_local_state_comment : 해당 노드가 클러스터의 멤버인지를 확인

wsrep_ready : 노드가 준비된 상태



## docker 내에서 클러스터 시작 (첫번째 클러스터)

$ sed -i 's/^safe_to_bootstrap:.*/safe_to_bootstrap: 1/' /var/lib/mysql/grastate.dat || :

$ docker-entrypoint.sh mysqld --wsrep-new-cluster


## docker 내에서 클러스터 시작 (두번째, 세번째 클러스터)

$ sed -i 's/^safe_to_bootstrap:.*/safe_to_bootstrap: 1/' /var/lib/mysql/grastate.dat || :

$ docker-entrypoint.sh mysqld







반응형
Posted by seungkyua@gmail.com
,