- Hyperauth
- OIDC ์ SSO ํ๋กํ ์ฝ์ ์ง์ํ๋ ์ธ์ฆ์๋ฒ๋ก์จ keycloak ์ ๋ฐํ์ผ๋ก ์ฌ๋ฌ ๊ธฐ๋ฅ์ ์ถ๊ฐํจ
- hyperauth
- postgres
- postgres:9.6.2-alpine
- zookeeper
- wurstmeister/zookeeper:3.4.6
- kafka
- wurstmeister/kafka:2.12-2.0.1
cpu : 300m memory: 300Mi
cpu: 300 memory: 300Mi Storage: 100Gi
cpu : 100m memory: 100Mi Storage: 5Gi
cpu : 100m memory: 100Mi Storage: 5Gi
- Java binary
- jq binary
- Storage class
- ์๋ ๋ช
๋ น์ด๋ฅผ ํตํด storage class๊ฐ ์ค์น๋์ด ์๋์ง ํ์ธํ๋ค.
$ kubectl get storageclass
- ๋ง์ฝ ์๋ฌด storage class๊ฐ ์๋ค๋ฉด ์๋ ๋งํฌ๋ก ์ด๋ํ์ฌ rook-ceph ์ค์นํ๋ค.
- Storage class๋ ์์ง๋ง default๋ก ์ค์ ๋ ๊ฒ์ด ์๋ค๋ฉด ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํ๋ค.
$ kubectl patch storageclass csi-cephfs-sc -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
- csi-cephfs-sc๋ ์ ๋งํฌ๋ก rook-ceph๋ฅผ ์ค์นํ์ ๋ ์์ฑ๋๋ storage class์ด๋ฉฐ ๋ค๋ฅธ storage class๋ฅผ default๋ก ์ฌ์ฉํด๋ ๋ฌด๊ดํ๋ค.
- ์๋ ๋ช
๋ น์ด๋ฅผ ํตํด storage class๊ฐ ์ค์น๋์ด ์๋์ง ํ์ธํ๋ค.
-
ํ์๋ง์์ ์ค์นํ๋ ๊ฒฝ์ฐ ์ฌ์ฉํ๋ image repository์ ํ์ํ ์ด๋ฏธ์ง๋ฅผ pushํ๋ค.
- ์์ ๋๋ ํ ๋ฆฌ ์์ฑ ๋ฐ ํ๊ฒฝ ์ค์
$ mkdir -p ~/hyperauth-install # For Hyperauth $ export HYPERAUTH_HOME=~/hyperauth-install $ cd ${HYPERAUTH_HOME} $ export POSTGRES_VERSION=9.6.2-alpine $ export HYPERAUTH_VERSION=<tag1> $ export REGISTRY=<REGISTRY_IP_PORT> * <tag1>์๋ ์ค์นํ hyperauth ๋ฒ์ ๋ช ์ ์์: $ export HYPERAUTH_VERSION=1.1.1.10 * <REGISTRY_IP_PORT>์๋ ํ์๋ง Docker Registry IP:PORT๋ช ์ ์์: $ export REGISTRY=192.168.6.110:5000
- ์ธ๋ถ ๋คํธ์ํฌ ํต์ ์ด ๊ฐ๋ฅํ ํ๊ฒฝ์์ ํ์ํ ์ด๋ฏธ์ง๋ฅผ ๋ค์ด๋ฐ๋๋ค.
# postgres $ sudo docker pull postgres:${POSTGRES_VERSION} $ sudo docker save postgres:${POSTGRES_VERSION} > postgres_${POSTGRES_VERSION}.tar # hyperauth $ sudo docker pull tmaxcloudck/hyperauth:b${HYPERAUTH_VERSION} $ sudo docker save tmaxcloudck/hyperauth:b${HYPERAUTH_VERSION} > hyperauth_b${HYPERAUTH_VERSION}.tar
-
์์ ๊ณผ์ ์์ ์์ฑํ tar ํ์ผ๋ค์
ํ์๋ง ํ๊ฒฝ์ผ๋ก ์ด๋์ํจ ๋ค ์ฌ์ฉํ๋ ค๋ registry์ ์ด๋ฏธ์ง๋ฅผ pushํ๋ค.- ์ด๋ฏธ์ง load ๋ฐ push
# Load Images $ sudo docker load < postgres_${POSTGRES_VERSION}.tar $ sudo docker load < hyperauth_b${HYPERAUTH_VERSION}.tar # Change Image's Tag For Private Registry $ sudo docker tag postgres:${POSTGRES_VERSION} ${REGISTRY}/postgres:${POSTGRES_VERSION} $ sudo docker tag tmaxcloudck/hyperauth:b${HYPERAUTH_VERSION} ${REGISTRY}/hyperauth:b${HYPERAUTH_VERSION} # Push Images $ sudo docker push ${REGISTRY}/postgres:${POSTGRES_VERSION} $ sudo docker push ${REGISTRY}/hyperauth:b${HYPERAUTH_VERSION}
- ์ด๊ธฐํ ์์
- SSL ์ธ์ฆ์ ์์ฑ
- HyperAuth Deployment ์์ฑ
- Kafka Topic Server ์ค์น
- Kubernetes OIDC ์ฐ๋
์ถ๊ฐ1. [External-OIDC-Provider ์ฐ๋]
- ๋ชฉ์ :
HyperAuth ๊ตฌ์ถ์ ์ํ ์ด๊ธฐํ ์์ , Secret์์ฑ ๋ฐ DB ๊ตฌ์ถ, Yaml ๋ฒ์ ์์ - ์๋์ command๋ฅผ ์์ ํ์ฌ ์ฌ์ฉํ๊ณ ์ ํ๋ image ๋ฒ์ ์ ๋ณด๋ฅผ ์์ ํ๋ค.
$ export POSTGRES_VERSION=9.6.2-alpine
$ sed -i 's/POSTGRES_VERSION/'${POSTGRES_VERSION}'/g' 1.initialization.yaml
$ export HYPERAUTH_VERSION=b1.1.1.10
$ sed -i 's/HYPERAUTH_VERSION/'${HYPERAUTH_VERSION}'/g' 2.hyperauth_deployment.yaml- ์์ฑ ์์ :
- kakfa namespace์ strimzi-cluster-operator๊ฐ ๊น๋ ค์์ง ์์ผ๋ฉด, strimzi-cluster-operator.yaml ์คํ
ex) kubectl apply -f strimzi-cluster-operator.yaml) - 1.initialization.yaml ์คํ
ex) kubectl apply -f 1.initialization.yaml)
- kakfa namespace์ strimzi-cluster-operator๊ฐ ๊น๋ ค์์ง ์์ผ๋ฉด, strimzi-cluster-operator.yaml ์คํ
- ๋น๊ณ : ์๋ ๋ช ๋ น์ด ์ํ ํ, Postgre Admin ์ ์ ํ์ธ
$ kubectl exec -it $(kubectl get pods -n hyperauth | grep postgre | cut -d ' ' -f1) -n hyperauth -- bash
$ psql -U keycloak keycloak- ๋ชฉ์ :
HTTPS ์ธ์ฆ์ ์ํ ์ธ์ฆ์, kafka์์ ํต์ ์ ์ํ keystore, truststore๋ฅผ ์์ฑํ๊ณ secret์ผ๋ก ๋ณํ - ์์ฑ ์์ :
- cert-manager๊ฐ ์ค์น๋์ด ์๊ณ , tmaxcloud-issuer (ClusterIssuer) ๊ฐ ์์ฑ๋์ด ์๋ค๊ณ ๊ฐ์ ํ๋ค.
- cert-manager ์ค์น๋ https://cert-manager.io/docs/installation
- ์์ฑ์ด ์๋์ด ์๋ ๊ฒฝ์ฐ, tmaxcloud-issuer.yaml ์คํ
ex) kubectl apply -f tmaxcloud-issuer.yaml)
- hyperauth_certs.yaml ์ ๋ณ์๋ฅผ ์ํฉ์ ๋ง๊ฒ ์นํํ๋ค. ์์ฐ๋ ๋ณ์ ๋ถ๋ถ์ ์ง์์ค๋ค.
- Hyperauth
- Hyperauth๋ฅผ IP๋ก ๋ ธ์ถํ๋ ๊ฒฝ์ฐ, {HYPERAUTH_EXTERNAL_IP} ์ธํ , dnsName ๋ถ๋ถ ์ ์ฒด ์ญ์
- Hyperauth๋ฅผ DNS๋ก ๋ ธ์ถํ๋ ๊ฒฝ์ฐ, {HYPERAUTH_EXTERNAL_DNS} ์ธํ , ipAddresses ๋ถ๋ถ ์ ์ฒด ์ญ์
- Hyperauth
- hyperauth_certs.yaml ์คํ
ex) kubectl apply -f hyperauth_certs.yaml) - Hyperauth Namespace์ hyperauth-https-secret, hyperauth-kafka-jks, kafka-jks Secret์ด ์์ฑ๋๊ฑธ ํ์ธํ๋ค.
- cert-manager๊ฐ ์ค์น๋์ด ์๊ณ , tmaxcloud-issuer (ClusterIssuer) ๊ฐ ์์ฑ๋์ด ์๋ค๊ณ ๊ฐ์ ํ๋ค.
$ kubectl get secrets -n hyperauth* hyperauth-https-secret์ผ๋ก ๋ถํฐ root-ca, hyperauth ์ธ์ฆ์๋ฅผ ์ถ์ถํด์ kubernetes pki ์ ์์นํ๋ค.
$ kubectl get secret hyperauth-https-secret -n hyperauth -o jsonpath="{['data']['tls\.crt']}" | base64 -d > ./hyperauth.crt
$ kubectl get secret hyperauth-https-secret -n hyperauth -o jsonpath="{['data']['ca\.crt']}" | base64 -d > ./hypercloud-root-ca.crt
$ cp ./hyperauth.crt /etc/kubernetes/pki/hyperauth.crt
$ cp ./hypercloud-root-ca.crt /etc/kubernetes/pki/hypercloud-root-ca.crt- ๋น๊ณ :
- Kubernetes Master๊ฐ ๋ค์คํ ๋ ๊ฒฝ์ฐ, hypercloud-root-ca.crt, hyperauth.crt๋ฅผ ๊ฐ Master ๋ ธ๋๋ค์ /etc/kubernetes/pki/hypercloud-root-ca.crt, /etc/kubernetes/pki/hyperauth.crt ๋ก cp
- ๋ชฉ์ :
HyperAuth ์ค์น - ์์ฑ ์์ :
- 2.hyperauth_deployment.yaml ์คํ
ex) kubectl apply -f 2.hyperauth_deployment.yaml - HyperAuth Admin Console์ ์ ์ ํ์ธ
kubectl get svc hyperauth -n hyperauth๋ช ๋ น์ด๋ก IP ํ์ธ- ๊ณ์ : admin/admin
- 2.hyperauth_deployment.yaml ์คํ
- ๋น๊ณ :
- K8s admin ๊ธฐ๋ณธ ๊ณ์ ์ ๋ณด : hc-admin@tmax.co.kr/Tmaxadmin1!
- HyperAuth User ๋ฉ๋ด์์ ๋น๋ฐ๋ฒํธ๋ ๋ณ๊ฒฝ ๊ฐ๋ฅ, ID๋ฅผ ์ํด์๋ clusterrole๋ ๋ณ๊ฒฝ ํ์
- ๋ชฉ์ :
Hyperauth์ Event๋ฅผ Subscribe ํ ์ ์๋ kafka server ์ค์น - ์์ฑ ์์ :
- 3.kafka_deployment.yaml ์คํ
ex) kubectl apply -f 3.kafka_deployment.yaml
- 3.kafka_deployment.yaml ์คํ
- ๋น๊ณ :
- hyperauth ์ด๋ฏธ์ง tmaxcloudck/hyperauth:b1.0.15.31 ์ดํ๋ถํฐ ์ค์น ์ ์ฉํ ๊ฒ!
- kafka_client.yaml ๋ก pub/subํ
์คํธ ๊ฐ๋ฅ
- kafka_client pod์ ์ ์ ํ
- Producer :
export PASSWORD=tmax@23 export KAFKA_OPTS=" \ -Djavax.net.ssl.trustStore=/opt/kafka/certificates/truststore.jks \ -Djavax.net.ssl.trustStorePassword=$PASSWORD \ -Djavax.net.ssl.trustStoreType=PKCS12" /opt/kafka/bin/kafka-console-producer.sh --broker-list \ kafka-kafka-bootstrap.hyperauth:9092 --topic tmax\ --producer-property 'security.protocol=SSL'
- Consumer :
export PASSWORD=tmax@23 export KAFKA_OPTS=" \ -Djavax.net.ssl.trustStore=/opt/kafka/certificates/truststore.jks \ -Djavax.net.ssl.trustStorePassword=$PASSWORD \ -Djavax.net.ssl.trustStoreType=PKCS12" /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server \ kafka-kafka-bootstrap.hyperauth:9092 --topic tmax\ --consumer-property 'security.protocol=SSL' \ --group consumer1
- kafka_client pod์ ์ ์ ํ
-
๋ชฉ์ :
Kubernetes์ RBAC ์์คํ ๊ณผ HyperAuth ์ธ์ฆ ์ฐ๋ -
์์ฑ ์์ :
- Kubernetes Cluster Master Node์ ์ ์
- {HYPERAUTH_SERVICE_IP} = $(kubectl describe service hyperauth -n hyperauth | grep 'LoadBalancer Ingress' | cut -d ' ' -f7)
/etc/kubernetes/manifests/kube-apiserver.yaml์ spec.containers[0].command[] ์ ์ ์๋ command๋ฅผ ์ถ๊ฐ
--oidc-issuer-url=https://{HYPERAUTH_SERVICE_IP}/auth/realms/tmax --oidc-client-id=hypercloud5 --oidc-username-claim=preferred_username --oidc-username-prefix=- --oidc-groups-claim=group --oidc-ca-file=/etc/kubernetes/pki/hyperauth.crt
-
๋น๊ณ :
- ์๋์ผ๋ก kube-apiserver ๊ฐ ์ฌ๊ธฐ๋ ๋จ
-
๋ชฉ์ :
Prometheus ๋ชจ๋ํฐ๋ง ์์คํ ๊ณผ HyperAuth ์ด๋ฒคํธ metrics ์ฐ๋ -
ํ์ ์๊ฑด
- Prometheus ์ค์น : https://github.com/tmax-cloud/install-prometheus ์ฐธ์กฐ
- Admin Console (tmax realm) - Events - Config - Events Config : prometheus-metric-listener ์ถ๊ฐ
- 1.initialization.yaml๋ฅผ ์ฐธ๊ณ ํ์ฌ passwords Secret์ HYPERAUTH_ADMIN์ ์ถ๊ฐํ๋ค. (hyperauth master realm admin์ ์์ด๋๋ฅผ base64 encoding ํ์ฌ ์์ฑ)
-
์์ฑ ์์ :
- ServiceMonitor ์์ฑ
- 4.hyperauth_service_pod_monitor.yaml ์คํ
ex) kubectl apply -f 4.hyperauth_service_pod_monitor.yaml
-
๋น๊ณ :
- ์๋์ผ๋ก Prometheus๊ฐ ์์ง์ ์์ํจ
- grafana dashboard import
- grafana - import - https://github.com/tmax-cloud/install-hyperauth/blob/main/manifest/hyperauth_grafana_dashboard.json ๋ด์ฉ ๋ถ์ฌ๋ฃ๊ธฐ
- grafana - import - https://github.com/tmax-cloud/install-hyperauth/blob/main/manifest/kafka_grafana_dashboard.json ๋ด์ฉ ๋ถ์ฌ๋ฃ๊ธฐ
- grafana - import - https://github.com/tmax-cloud/install-hyperauth/blob/main/manifest/kafka_exporter_grafana_dashboard.json ๋ด์ฉ ๋ถ์ฌ๋ฃ๊ธฐ
- grafana - import - https://github.com/tmax-cloud/install-hyperauth/blob/main/manifest/zookeeper_grafana_dashboard.json ๋ด์ฉ ๋ถ์ฌ๋ฃ๊ธฐ
- ๋ชฉ์ : Initech์ SSO์์คํ ์ External-OIDC-Provider๋ฅผ ํตํด์ IDP๋ก ์ฌ์ฉ
- ์์ฑ ์์
- External-OIDC-Provider ์์ฑ : External-OIDC_Provider ์ค์น๊ฐ์ด๋
- 2.hyperauth_deployment.yaml ์์
#Enable ~ if use External-oidc-provider๋ก ์ฃผ์ ์ฒ๋ฆฌ๋ yaml ํ๋๋ฅผ ๋ชจ๋ ์ฃผ์ ํด์ - External-OIDC-Provider์ ๋๋ฉ์ธ (SERVER_URL ๋ณ์)์ ์๋ ENV๋ก ๋ฑ๋ก
- name : EXTERNAL_OIDC_PROVIDER_AUTH_URL value : https:// {external-oidc-provider.SERVER_URL} /externalauth - name : EXTERNAL_OIDC_PROVIDER_TOKEN_URL value : https:// {external-oidc-provider.SERVER_URL} /token - name : EXTERNAL_OIDC_PROVIDER_PROFILE_URL value : https:// {external-oidc-provider.SERVER_URL} /profile
- ์ดํ ๋ณธ ์ค์น๊ฐ์ด๋๋ฅผ 1. ์ด๊ธฐํ ์์ ๋ถํฐ ์งํ
- hyperauth_traefik_ingress.yaml ์์ host ๋ฐ hosts๋ฅผ ํ๊ฒฝ์ ๋ง๋ dns๋ก ์์ ํ๊ณ applyํ๋ค.
- ๋ชจ๋ ๋ง์คํฐ ๋
ธ๋์ ๊ดํด์ self-signed ์ธ์ฆ์์ ๊ฒฝ์ฐ, os์ ca store์ ๋ฑ๋กํ๋ ๊ณผ์ ์ ๊ฑฐ์ณ์ผ k8s๊ฐ ๊ณต์ธ ์ธ์ฆ์๋ก ์จ ์ ๋ขฐํ๋ค.
- hypercloud-root-ca.crt, hyperauth.crt๋ฅผ /etc/pki/ca-trust/source/anchors/ ๋ฐ์ ๋ณต์ฌํ๋ค. (centOS ๊ธฐ์ค)
- update-ca-trust