Table of Contents | ||||
---|---|---|---|---|
|
...
Internal Ports (Backend Server 간): Trusted Network 구간
8000 : Salt-API Server - CH Server와 데이터 송수신.
9094 : Kapacitor - InfluxDB와 데이터 송수신.
Intermediate Ports (Agent ↔︎ Backend Server 간): Semi-Trusted Network 구간
Warning |
---|
아래 포트들은 모니터링 대상 호스트들(MO: Managed Objects)과의 통신에 사용됩니다. 아래 설정 예시와 같이 firewalld filter를 사용하거나, 혹은 tcp_wrappers 등을 사용하여 hosts.allow, hosts.deny 등에 ACL을 설정할 수 있습니다. |
4505-4506 : Salt-Master - Salt-Minion과 데이터 송수신.
8086 : InfluxDB - telegraf로부터 데이터 수신.
아래는 firewalld
설정 파일 예시이며,
Status | ||||
---|---|---|---|---|
|
Code Block | ||
---|---|---|
| ||
<!-- /etc/firewalld/zones/public.xml --> <?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description>For use in public areas.</description> <service name="ssh"/> <service name="dhcpv6-client"/> <port protocol="tcp" port="443"/> <rule family="ipv4"> <source address="xxx.xxx.xxx.0/24"/> <port protocol="tcp" port="4505-4506"/> <accept/> </rule> <rule family="ipv4"> <source address="xxx.xxx.xxx.xxx"/> <port protocol="tcp" port="8000"/> <accept/> </rule> <rule family="ipv4"> <source address="xxx.xxx.xxx.xxx"/> <port protocol="tcp" port="8086"/> <accept/> </rule> <rule family="ipv4"> <source address="xxx.xxx.xxx.xxx"/> <port protocol="tcp" port="9094"/> <accept/> </rule> </zone> |
...
conda 환경 변수 설정을 위해 conda init
명령어를 입력해야 합니다.
Code Block |
---|
$ /opt/miniconda3/bin/conda init |
Info |
Zsh의 경우 아래의 명령어를 입력 export PATH=/opt/miniconda3/bin/ :$PATH $ conda initzsh |
conda 기본 환경을 비활성화
Info |
---|
기본 환경을 비활성화 하려면 아래의 명령어를 입력해야 합니다. |
...
https://github.com/snetsystems/salt/releases 에서 원하는 버전의 인스톨 파일들을 다운로드 합니다.
여기서는 “3001.4-615-ge56e905g1d946bf
”버전으로 인스톨 할 것이며, 관련 파일들을 적당한 경로에 다운로드 합니다.
Conda 가상환경 압축 파일: 예>
saltenv-3001.4-615-ge56e905g1d946bf-linux.tar.gz
install_salt_svc_for_conda_centos7systemd.sh
saltenv unpack
/opt/miniconda3/envs/
에 saltenv-3001.4-615-ge56e905g1d946bf-linux.tar.gz
를 압축 해제합니다.
그리고 나서, conda env list
로 확인하면 정상 등록되어 있을 것 입니다.
Code Block | ||
---|---|---|
| ||
$ tar xzf saltenv-3001.4-615-ge56e905g1d946bf-linux.tar.gz -C /opt/miniconda3/envs/ $ pwd /opt/miniconda3/envs $ ll total 219044 drwxr-xr-x. 13 root root 195 May 16 11:08 saltenv $ conda env list # conda environments: # base * /opt/miniconda3 saltenv /opt/miniconda3/envs/saltenv |
...
Salt-Master와 Salt-API의 Config 설정.
Config path
Config path :
Code Block |
---|
$ mkdir -p /opt/miniconda3/envs/saltenv/master/etc/salt && vim /opt/miniconda3/envs/saltenv/master/etc/salt/master |
Note |
---|
|
Code Block | ||
---|---|---|
| ||
## log_level ## # One of 'garbage', 'trace', 'debug', info', 'warning'(default), 'error', 'critical'. log_level: info root_dir: /opt/miniconda3/envs/saltenv/master ##### Primary configuration settings ##### ########################################## # The address of the interface to bind to: interface: x.x.x.x # The tcp port used by the publisher: publish_port: 4505 # Allow minions to push files to the master. This is disabled by default, for # security purposes. # file_recv: True ##### State System settings ##### ########################################## # The state system uses a "top" file to tell the minions what environment to # use and what modules to use. The state_top file is defined relative to the # root of the base environment as defined in "File Server settings" below. state_top: top.sls ##### File Server settings ##### ########################################## # Salt runs a lightweight file server written in zeromq to deliver files to # minions. This file server is built into the master daemon and does not # require a dedicated port. # The file server works on environments passed to the master, each environment # can have multiple root directories, the subdirectories in the multiple file # roots cannot match, otherwise the downloaded files will not be able to be # reliably ensured. A base environment is required to house the top file. file_roots: base: - /srv/salt/prod # File Server Backend # # Salt supports a modular fileserver backend system, this system allows # the salt master to link directly to third party systems to gather and # manage the files available to minions. Multiple backends can be # configured and will be searched for the requested file in the order in which # they are defined here. The default setting only enables the standard backend # "roots" which uses the "file_roots" option. fileserver_backend: - roots ##### Security settings ##### ########################################## # The external auth system uses the Salt auth modules to authenticate and # validate users to access areas of the Salt system. external_auth: pam: saltdev: - .* - '@runner' - '@wheel' - '@jobs' # Allow eauth users to specify the expiry time of the tokens they generate. # A boolean applies to all users or a dictionary of whitelisted eauth backends # and usernames may be given. token_expire_user_override: pam: - saltdev ##### API Server settings ##### ########################################## rest_cherrypy: port: 80008887 disablessl_ssl: True |
...
crt: /usr/lib/cloudhub/key/cloudhub_self_signed.crt
ssl_key: /usr/lib/cloudhub/key/cloudhub_self_signed.key
rest_cherrypy_ssl: True |
Salt-Minion 설정
Warning |
---|
|
Note |
---|
|
Config path: $ vim
Code Block |
---|
$ mkdir -p /opt/miniconda3/envs/saltenv/minion/etc/salt && vim /opt/miniconda3/envs/saltenv/minion/etc/salt/minion |
Code Block | ||
---|---|---|
| ||
## log_level ##
# One of 'garbage', 'trace', 'debug', info', 'warning'(default), 'error', 'critical'.
log_level: info
root_dir: /opt/miniconda3/envs/saltenv/minion
master: <master ip address>
id: <유일한 minion id 설정해야 하며, 생략 시, hostname = minion id> |
계정 생성 및 패스워드 설정
Note |
---|
아래 추가된 saltdev에 대한 password는 추후 salt-api authentication을 위한 pam_token를 발급 받는데 쓰이므로, 잘 기억해두어야 합니다. |
Code Block | ||
---|---|---|
| ||
$ useradd saltdev $ passwd <password> Changing password for user saltdev. New password: |
...
$ ./install_salt_svc_for_conda_centos7systemd.sh
를 실행하면 아래 예제와 같이 서비스가 설치되며, 자동 실행됩니다.
Code Block | ||
---|---|---|
| ||
# install_salt_svc_for_conda_centos7systemd.sh 사용법 $ ./install_salt_svc_for_conda_centos7systemd.sh -h usage: ./install_salt_svc_for_conda_centos7systemd.sh [options] Install SNET salt services -p Set installed miniconda prefix path (default: /opt/miniconda3/envs/saltenv |
...
Code Block | ||
---|---|---|
| ||
$ ./install_salt_svc_for_conda_centos7systemd.sh Do you want to install salt-minion only? [y/n]n Do you want to start whole 'snet-salt' services? [y/n]y |
...
Code Block | ||
---|---|---|
| ||
$ ./install_salt_svc_for_conda_centos7systemd.sh Do you want to install salt-minion only? [y/n]y Do you want to start the 'snet-salt-minion' service? [y/n]y |
...
Code Block | ||
---|---|---|
| ||
$ mkdir -p /srv/salt/prod/telegraf # Telegraf package path $ cd /srv/salt/prod/telegraf $ wget https://github.com/snetsystems/telegraf/releases/download/v1.1923.34-snet-1/telegraf-1.1923.34-snet-1-1_.x86_64.rpm |
Install CloudHub Portal
...
Install
$ yum localinstall cloudhubCloudHub-01.4.92.1~17fe47a520d7bd.x86_64.rpm
Configure
Info |
---|
아래 Config의 자세한 내용은 CloudHub Document > Introduction > Getting started > Basic Configure CloudHub를 참고하세요. |
$ vim /etc/systemd/system/multi-user.target.wants/cloudhub.service
Code Block language yaml [Unit] After=network-online.target [Service] User=root Group=root Environment="HOST=0.0.0.0" Environment="PORT=443" # default: 88888888" Environment="TLS_CERTIFICATE=/usr/lib/cloudhub/key/cloudhub_self_signed.pem" #Environment="TLS_PRIVATE_KEY=my.key" Environment="BOLT_PATH=/var/lib/cloudhub/cloudhub-v1.db" #Environment="ETCD_ENDPOINTS={ETCD_CLIENT_IP}:2379" Environment="CANNED_PATH=/usr/share/cloudhub/cloudhub-canned" Environment="PROTOBOARDS_PATH=/usr/share/cloudhub/cloudhub-protoboards" EnvironmentFile=-/etc/default/cloudhub ExecStart=/usr/bin/cloudhub $CLOUDHUB_OPTS KillMode=control-group Restart=on-failure [Install] WantedBy=multi-user.target
localhost 인증서(cloudhub_self_signed.pem) 발급
Code Block $ cd /usr/lib/cloudhub/key/ $ openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout cloudhub_self_signed.pem -out cloudhub_self_signed.pem -subj "/CN=localhost" -days 365
<salt_token
> 발급
/wiki/spaces/CM/$ openssl rsa -in cloudhub_self_signed.pem -text > cloudhub_self_signed.key $ openssl x509 -inform PEM -in cloudhub_self_signed.pem -out cloudhub_self_signed.crt
<salt_token
> 발급
/wiki/spaces/CM/pages/254050538
위 페이지 접근 권한이 없는 경우에는 Snetsystems CloudHub 팀에 문의/발급 받은 후,Status colour Purple title 노트
아래 4번-k=salt:<salt_token>
에 기입하세요.$ vim /etc/default/cloudhub
Code Block language yaml CLOUDHUB_OPTS="-l=debug \ --auth-duration=0 \ -t=74c1e9e2450886060b5bf736b935cd0bf960837f \ -i=any \ -s=any \ -u=salt:http://{salt-master-ip}:8000/run \ -k=salt:<salt_token> \ -u=vsphere:on \ -u=aws:on \ -u=k8s:on \ --login-auth-type=basic \ --password-policy='(?=.*[0-9]{1,50})(?=.*[~`!@#$%\\^&*()-+=]{1,50})(?=.*[a-zA-Z]{2,50}).{8,50}$' \ --password-policy-message='Enter at least 8 digits using at least 1 number and at least 1 special sentence, and at least 2 English characters.' \ --mail-subject='[Notifiy] $user_id Password is reset' \ --mail-body-message='Reset OTP for $user_id is '$user_pw'.<br>Do not forget this!<br>This OTP will use just once when login into cloudhub.<br>Then you must set up the new password' \ --kapacitor-url=http://{Kapacitor_IP}:9094 \ --influxdb-url=http://{InfluxDB_IP}:8086 \ --retry-policy=count:3 \ --retry-policy=delaytime:5 \ --retry-policy=type:delay"
...
$ sudo systemctl {start|stop|restart} cloudhub
Nginx 설치
yum 외부 저장소 추가
Code Block |
---|
$ cd /etc/yum.repos.d/
$ ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo microsoft-prod.repo |
/etc/yum.repos.d/ 경로에 nginx.repo 파일 추가
Code Block |
---|
$ vim /etc/yum.repos.d/nginx.repo |
nginx.repo 파일
Code Block |
---|
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1 |
yum install 명령어를 이용해서 설치합니다.
Code Block |
---|
$ yum install -y nginx |
Info |
---|
SELinux가 enforce 모드로 되어 있다면 아래의 명령어를 입력하여 http port를 열어 주어야 합니다. |
Code Block |
---|
$ semanage port -a -t http_port_t -p tcp 443
$ semanage port -a -t http_port_t -p tcp 8000
$ semanage port -a -t http_port_t -p tcp 8888
$ semanage port -a -t http_port_t -p tcp 8887 |
Note |
---|
ValueError: Port tcp/xxxx already defined 오류가 발생하는 경우 아래 명령어를 통해 해결합니다. |
Code Block |
---|
$ semanage port -m -t http_port_t -p tcp xxxx |
Nginx 서버 설정
Code Block |
---|
$ vim /etc/nginx/conf.d/default.conf |
Code Block |
---|
upstream app {
server {Cloudhub-Portal-ip}:8888;
}
upstream salt {
server {salt-master-ip}:8887;
}
server {
listen 8000 ssl http2;
server_name _;
ssl_certificate /usr/lib/cloudhub/key/cloudhub_self_signed.crt;
ssl_certificate_key /usr/lib/cloudhub/key/cloudhub_self_signed.key;
location / {
proxy_pass https://salt;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 443 ssl http2 ;
server_name _;
#access_log /var/log/nginx/proxy/access.log;
#error_log /var/log/nginx/proxy/error.log;
ssl_certificate /usr/lib/cloudhub/key/cloudhub_self_signed.crt;
ssl_certificate_key /usr/lib/cloudhub/key/cloudhub_self_signed.key;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
proxy_pass https://app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /cloudhub/v1/WebTerminalHandler {
proxy_http_version 1.1;
proxy_pass https://app;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 28800s;
proxy_send_timeout 28800s;
}
} |
Nginx start
Code Block |
---|
$ sudo systemctl start nginx
$ sudo systemctl enable nginx |
CloudHub Portal UI 초기 설정
Steps
...
Status | ||||
---|---|---|---|---|
|