1. 개요
클러스터 외부에서 object storage에 접근하여 이미지 등을 다운로드하기까지
2. 사용자 생성
2.1. 사용자 생성
- Object-user.yaml (아래 Name과 displayName은 원하는 이름으로 변경하여 생성)
apiVersion: ceph.rook.io/v1
kind: CephObjectStoreUser
metadata:
name: osckorea-devops
namespace: rook-ceph
spec:
store: ceph-objectstore
displayName: "osckorea-devops"
|
- 사용자 생성
kubectl apply -f object-user.yaml
|
2.2. 확인
- UI - Object Gateway - 사용자에서 확인
2.3. 해당 사용자에게 생성된 Secret 확인
- 생성된 사용자에게 로그인된 secret (AccessKey/SecretKey) 확인하는 방법
- 비밀 생성되어 있는지 확인
$ kubectl describe secret rook-ceph-object-user-ceph-objectstore-osckorea-devops
Name: rook-ceph-object-user-ceph-objectstore-osckorea-devops
Namespace: rook-ceph
Labels: app=rook-ceph-rgw
rook_cluster=rook-ceph
rook_object_store=ceph-objectstore
user=osckorea-devops
Annotations: <none>
Type: kubernetes.io/rook
Data
====
AccessKey: 20 bytes
Endpoint: 54 bytes
SecretKey: 40 bytes
|
- Accesskey와 SecretKey 가져오기
$ kubectl -n rook-ceph get secret rook-ceph-object-user-ceph-objectstore-osckorea-devops -o jsonpath='{.data.AccessKey}' | base64 --decode
xxxxxxxxx
$ kubectl -n rook-ceph get secret rook-ceph-object-user-ceph-objectstore-osckorea-devops -o jsonpath='{.data.SecretKey}' | base64 --decode
yyyyyyyy
|
3. 외부 서비스 생성
3.1. rgw 외부 서비스 생성
이 작업은 외부에서 접근 가능한 서비스를 생성하는 작업으로 한 번만 현장에 존재하는(반복할 필요 없음)
- rgw-external.yaml
apiVersion: v1
kind: Service
metadata:
name: rook-ceph-rgw-ceph-external
namespace: rook-ceph
labels:
app: rook-ceph-rgw
rook_cluster: rook-ceph
rook_object_store: ceph-objectstore
spec:
ports:
- name: rgw
port: 80
protocol: TCP
targetPort: 8080
selector:
app: rook-ceph-rgw
rook_cluster: rook-ceph
rook_object_store: ceph-objectstore
sessionAffinity: None
type: NodePort
|
- 서비스 배포
kubectl apply -f rgw-external.yaml
|
3.2. 확인
- 서비스 확인 - 아래처럼 원래 있던 아이폰 서비스 외부로 nodeport로 열 수 있는 서비스가 하나 더 생성됨 확인
$ kubectl get service | grep rgw
rook-ceph-rgw-ceph-external NodePort 10.43.91.79 <none> 80:32541/TCP 46h
rook-ceph-rgw-ceph-objectstore ClusterIP 10.43.212.81 <none> 80/TCP 14d
|
4. s3cmd
- 버킷을 생성하고 파일을 업로드하는 작업 등을 여러 언어로 사용할 수 있는 하나의 s3cmd 응용 프로그램을 설치하여 간단히 테스트할 수 있음
- 설치하다
sudo apt-get install s3cmd
|
- configure (어떤 object storage로 표기를 했는지에 대해 설정하는 내용)
- Access Key와 Secret Key에 위의 Secret에서 받아 두었던 내용 입력
- Region : us-east-1 입력 (실제 aws s3가 작성한 rook-ceph에 설치시 입력했던 region임)
- s3 엔드포인트 - 가상 IP 주소:NodePort
- DNS Style Bucket: 공란 (스페이스) 입력
- HTTP 프로토콜 사용: 아니요
$ s3cmd --configure
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: xxxxxxxxxx
Secret Key: yyyyyyyyyy
Default Region [US]:
Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: 172.22.21.121:32541
Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]:
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]: No
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:
New settings:
Access Key: LJAF9A2HFMZVHVX9ACAW
Secret Key: HFkT0pLLCP2fEoUOWsybYxWlbfrIdDbpaqPlu42d
Default Region: US
S3 Endpoint: 172.22.21.121:32541
DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.s3.amazonaws.com
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0
Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)
Now verifying that encryption works...
Not configured. Never mind.
Save settings? [y/N] y
Configuration saved to '/home/rihwang/.s3cfg'
|
5. 버킷 생성 및 파일 업로드
5.1. 버킷 생성
- public-bucket-from-cli라는 이름의 가방 생성시 -P옵션으로 Public으로 만듦
$ s3cmd mb -P s3://public-bucket-from-cli
Bucket 's3://public-bucket-from-cli/' created
|
- 확인
- Chrome에서 확인 - http://172.22.21.133:32541/public-bucket-from-cli
- s3cmd로 확인
$ s3cmd ls
2022-04-07 01:57 s3://public-bucket-from-cli
|
5.2. 파일 업로드
- 그림 파일 업로드 (역시 -P옵션으로 public으로 만듦)
$ s3cmd put -P knight_with_book.png s3://public-bucket-from-cli/knight_with_book-2.png
upload: 'knight_with_book.png' -> 's3://public-bucket-from-cli/knight_with_book-2.png' [1 of 1]
71984 of 71984 100% in 0s 1714.93 kB/s done
Public URL of the object is: http://172.22.21.121:32541/public-bucket-from-cli/knight_with_book-2.png
|
5.3. 버킷 안의 내용 보기
$ s3cmd ls s3://public-bucket-from-cli
2022-04-11 07:48 4685 s3://public-bucket-from-cli/computer.jpg
2022-04-07 02:28 71984 s3://public-bucket-from-cli/knight_with_book-2.png
2022-04-07 02:20 71984 s3://public-bucket-from-cli/knight_with_book.png
2022-04-11 07:51 7779 s3://public-bucket-from-cli/monitor.jpg
2022-04-11 05:42 8786 s3://public-bucket-from-cli/오트밀 (1).jpg
2022-04-11 07:27 8786 s3://public-bucket-from-cli/오트밀.jpg
|
5.4. 시험
- chrome에서 url로 파일 그림 보이는지 확인