디렉토리 구조 및 각 서비스 추가
This commit is contained in:
10
helm/argo-workflows/Lab/credentails/aws-secret.yaml
Normal file
10
helm/argo-workflows/Lab/credentails/aws-secret.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: aws-creds
|
||||
type: Opaque
|
||||
data:
|
||||
AWS_REGION: YXAtbm9ydGhlYXN0LTI=
|
||||
AWS_ACCESS_KEY_ID: QUtJQVhNVlZGM1RBVEhaTFlFSE4=
|
||||
AWS_SECRET_ACCESS_KEY: MEQ4WGdmK2gzU3hKQmhBUkdpbXhETUJJbTRMUFNmQmswNlRyaEkxSA==
|
||||
KMS_ARN: YXJuOmF3czprbXM6YXAtbm9ydGhlYXN0LTI6NTA4MjU5ODUxNDU3OmtleS9hNDhiMWU4OC1hOWJiLTRkODYtYTQ4MS1lZjU0ZTJmNDA0NTI=
|
||||
8
helm/argo-workflows/Lab/credentails/git-secret.yaml
Normal file
8
helm/argo-workflows/Lab/credentails/git-secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: git-credentials
|
||||
type: Opaque
|
||||
data:
|
||||
username: amFlaGVlLWp1bmc=
|
||||
password: Z2hwX0FBRnJ3eGI2ZDZvYXFGdzJaRTdhUmlPUmpwSzlVcjNuNkc3bA==
|
||||
18
helm/argo-workflows/Lab/credentails/kubeconfig.yaml
Normal file
18
helm/argo-workflows/Lab/credentails/kubeconfig.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMrRENDQWVDZ0F3SUJBZ0lNRnlXQnVlNTZlNTJFd2xzNU1BMEdDU3FHU0liM0RRRUJDd1VBTUJneEZqQVUKQmdOVkJBTVREV3QxWW1WeWJtVjBaWE10WTJFd0hoY05Nakl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3eW4yUHlJTEVWQwpQcDFMcStNUGJJdnNRcnZHQnZ2aURpUCs1SXJlVUYvZzNGU1JqQVNIaGxvZ0NwZFFjZkVlQnVXNkxYdksyNUJjCk9PbUVUcXpaMm40ZTlQMUg4M25nSHVDOEdwaU1iY1VaaFlLQ0hYSXU0MEdrdkl5R0wyZTF2Vks4a2o4PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
||||
server: https://api.k8s-prod.datasaker.io
|
||||
name: dsk-prod-cluster
|
||||
contexts:
|
||||
- context:
|
||||
cluster: dsk-prod-cluster
|
||||
user: monitor-ro
|
||||
name: dsk-prod-cluster
|
||||
current-context: dsk-prod-cluster
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: monitor-ro
|
||||
user:
|
||||
token: eyJhbGciOiJSUzI1NiIsImtpZCI6Ik9LMDAzSmljd1NydVNMYkc1cVg4Sk1qYW9QNDMxVEp2bmlGQ2FMaFQtQVUifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im1vbml0b3Itcm8tc2VjcmV0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6Im1vbml0b3Itcm8iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiI1ZTliZDYwNy0yZTllLTQwNWUtOGM1My00ZWU4Njg0ZTUzZjIiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6ZGVmYXVsdDptb25pdG9yLXJvIn0.otQZico3ewb89vgcZRRxP3MfWS-P25rhqahisz80Kku8XrbdiJZqff3lZxU1Snb9w1cTgvszEAB7yBDQqPWiFVKSZl8xedWJaraOHR7UvvnoclTeEtyrUNcMbG4bbljPk0sb-H-H3FR_xw6oJvRsWTSEq0z2ztMKp0R8ky4gQOl8hdFQ0eICGs1I6Gy69z9PuaVjhBNO3EIvMPJQcFtbgiXYBpAqKefRFnrJ5gW00cZhb0Jcc5OQkoTByGqMpsdCB4JpYmjA0qSo79G9JkN2iN2VaqvxUjc1MKIzpYr_2bN9PFIakue8qILVUaHQyUcSxPJN1Y0rwNVZ_xiyedhxLA
|
||||
8
helm/argo-workflows/Lab/credentails/my-kubeconfig.yaml
Normal file
8
helm/argo-workflows/Lab/credentails/my-kubeconfig.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: my-kubeconfig
|
||||
type: Opaque
|
||||
data:
|
||||
config: YXBpVmVyc2lvbjogdjEKY2x1c3RlcnM6Ci0gY2x1c3RlcjoKICAgIGNlcnRpZmljYXRlLWF1dGhvcml0eS1kYXRhOiBMUzB0TFMxQ1JVZEpUaUJEUlZKVVNVWkpRMEZVUlMwdExTMHRDazFKU1VNclJFTkRRV1ZEWjBGM1NVSkJaMGxOUm5sWFFuVmxOVFpsTlRKRmQyeHpOVTFCTUVkRFUzRkhVMGxpTTBSUlJVSkRkMVZCVFVKbmVFWnFRVlVLUW1kT1ZrSkJUVlJFVjNReFdXMVdlV0p0VmpCYVdFMTBXVEpGZDBob1kwNU5ha2w0VFZSQk1rMUVVWHBOVkVWNVYyaGpUazE2U1hoTlZFRXhUVVJSZWdwTlZFVjVWMnBCV1UxU1dYZEdRVmxFVmxGUlJFVjNNWEprVjBwc1kyMDFiR1JIVm5wTVYwNW9UVWxKUWtscVFVNUNaMnR4YUd0cFJ6bDNNRUpCVVVWR0NrRkJUME5CVVRoQlRVbEpRa05uUzBOQlVVVkJNRWxTZGxkSmNWVjNXblI0V2xaaFMyWXlNSGxGV0hOeVYyTldOelJ6VUZwSmEwcHdNMGhxVjJKTVUza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V055WlhRdWJtRnRaU0k2SW0xdmJtbDBiM0l0Y204dGMyVmpjbVYwSWl3aWEzVmlaWEp1WlhSbGN5NXBieTl6WlhKMmFXTmxZV05qYjNWdWRDOXpaWEoyYVdObExXRmpZMjkxYm5RdWJtRnRaU0k2SW0xdmJtbDBiM0l0Y204aUxDSnJkV0psY201bGRHVnpMbWx2TDNObGNuWnBZMlZoWTJOdmRXNTBMM05sY25acFkyVXRZV05qYjNWdWRDNTFhV1FpT2lJMVpUbGlaRFl3TnkweVpUbGxMVFF3TldVdE9HTTFNeTAwWldVNE5qZzBaVFV6WmpJaUxDSnpkV0lpT2lKemVYTjBaVzA2YzJWeWRtbGpaV0ZqWTI5MWJuUTZaR1ZtWVhWc2REcHRiMjVwZEc5eUxYSnZJbjAub3RRWmljbzNld2I4OXZnY1pSUnhQM01mV1MtUDI1cmhxYWhpc3o4MEtrdThYcmJkaUpacWZmM2xaeFUxU25iOXcxY1RndnN6RUFCN3lCRFFxUFdpRlZLU1psOHhlZFdKYXJhT0hSN1V2dm5vY2xUZUV0eXJVTmNNYkc0YmJsalBrMHNiLUgtSDNGUl94dzZvSnZSc1dUU0VxMHoyenRNS3AwUjhreTRnUU9sOGhkRlEwZUlDR3MxSTZHeTY5ejlQdWFWamhCTk8zRUl2TVBKUWNGdGJnaVhZQnBBcUtlZlJGbnJKNWdXMDBjWmhiMEpjYzVPUWtvVEJ5R3FNcHNkQ0I0SnBZbWpBMHFTbzc5RzlKa04yaU4yVmFxdnhVamMxTUtJenBZcl8yYk45UEZJYWt1ZThxSUxWVWFIUXlVY1N4UEpOMVkwcndOVlpfeGl5ZWRoeExBCg==
|
||||
|
||||
8
helm/argo-workflows/Lab/db-backup/bastion-ssh-key.yaml
Normal file
8
helm/argo-workflows/Lab/db-backup/bastion-ssh-key.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: bastion-ssh-key
|
||||
type: Opaque
|
||||
data:
|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2JXTkw0UXgxQ3AKZkRvbTNFdGFPbTUzUTR6QURTdC81NVJtbEUrZWpad09aZEw3bWdKb1l3QmVPRUQvaHJxSXYvOEtmOU0yWW9yQTl1TWp5ZwpQNEpsb1R5V2I0WlhCOEgrUDNrbS9aWWt5ZHpBTUhaTTN4RXZVZXFkNzlIWHlHVW5BRmdSeVdQMUJIZVBmcSt6Z1lFWnVzClBqeU1IZk9manF0T01BQUFBTmNtOXZkRUIwYlhBdGRHVnpkQUVDQXdRRkJnPT0KLS0tLS1FTkQgT1BFTlNTSCBQUklWQVRFIEtFWS0tLS0tCg==
|
||||
|
||||
71
helm/argo-workflows/Lab/db-backup/db-backup-cron.yaml
Normal file
71
helm/argo-workflows/Lab/db-backup/db-backup-cron.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: db-backup-cron
|
||||
spec:
|
||||
schedule: "0 5 * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: db-backup
|
||||
templates:
|
||||
- name: db-backup
|
||||
container:
|
||||
image: nexus2.exem-oss.org/dsk-middleware-backup:v2.0
|
||||
env:
|
||||
- name: sh_debug
|
||||
value: ''
|
||||
- name: MASTER_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: master_host
|
||||
- name: MONGO_MANIFEST_PORT
|
||||
value: '30111'
|
||||
- name: MONGO_DSK_PORT
|
||||
value: '30112'
|
||||
- name: MONGO_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: mongo_username
|
||||
- name: MONGO_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: mongo_password
|
||||
- name: POSTGRES_PORT
|
||||
value: '32098'
|
||||
- name: POSTGRES_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: postgres_username
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: postgres_password
|
||||
- name: S3_BUCKET
|
||||
value: 'dsk-middleware-backup'
|
||||
- name: sse
|
||||
value: 'aws:kms'
|
||||
- name: AWS_DEFAULT_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: kms_arn
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
11
helm/argo-workflows/Lab/db-backup/db-creds.yaml
Normal file
11
helm/argo-workflows/Lab/db-backup/db-creds.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: db-creds
|
||||
type: Opaque
|
||||
data:
|
||||
master_host: MTcyLjI0LjEyLjExMQ==
|
||||
mongo_username: cm9vdA==
|
||||
mongo_password: bW9uZ28jcGFzcw==
|
||||
postgres_username: cG9zdGdyZXM=
|
||||
postgres_password: cm9vdA==
|
||||
92
helm/argo-workflows/Lab/db-backup/test-workflow.yaml
Normal file
92
helm/argo-workflows/Lab/db-backup/test-workflow.yaml
Normal file
@@ -0,0 +1,92 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: db-backup-cron
|
||||
spec:
|
||||
schedule: "0 5 * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: db-backup
|
||||
templates:
|
||||
- name: db-backup
|
||||
container:
|
||||
image: nexus2.exem-oss.org/dsk-middleware-backup:v3.0
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
# SSH 키를 파일로 저장
|
||||
echo -n "$SSH_KEY" > /tmp/id_rsa
|
||||
chmod 600 /tmp/id_rsa
|
||||
cat /tmp/id_rsa
|
||||
# SSH 터널링 설정
|
||||
|
||||
ssh -i /tmp/id_rsa -fN -L $MONGO_MANIFEST_PORT:$MASTER_HOST:$MONGO_MANIFEST_PORT dev2@bastion.kr.datasaker.io -o StrictHostKeyChecking=no &
|
||||
ssh -i /tmp/id_rsa -fN -L $MONGO_DSK_PORT:$MASTER_HOST:$MONGO_DSK_PORT dev2@bastion.kr.datasaker.io -o StrictHostKeyChecking=no &
|
||||
ssh -i /tmp/id_rsa -fN -L $POSTGRES_PORT:$MASTER_HOST:$POSTGRES_PORT dev2@bastion.kr.datasaker.io -o StrictHostKeyChecking=no &
|
||||
chmod +x /backup.sh
|
||||
/backup.sh
|
||||
env:
|
||||
- name: SSH_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: bastion-ssh-key
|
||||
key: ssh-key
|
||||
- name: sh_debug
|
||||
value: ''
|
||||
- name: MASTER_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: master_host
|
||||
- name: MONGO_MANIFEST_PORT
|
||||
value: '30111'
|
||||
- name: MONGO_DSK_PORT
|
||||
value: '30112'
|
||||
- name: MONGO_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: mongo_username
|
||||
- name: MONGO_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: mongo_password
|
||||
- name: POSTGRES_PORT
|
||||
value: '32098'
|
||||
- name: POSTGRES_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: postgres_username
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: db-creds
|
||||
key: postgres_password
|
||||
- name: S3_BUCKET
|
||||
value: 'dsk-middleware-backup'
|
||||
- name: sse
|
||||
value: 'aws:kms'
|
||||
- name: AWS_DEFAULT_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: kms_arn
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
restartPolicy: OnFailure
|
||||
|
||||
190
helm/argo-workflows/Lab/script.sh
Normal file
190
helm/argo-workflows/Lab/script.sh
Normal file
@@ -0,0 +1,190 @@
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init (){
|
||||
datetime=`date "+%Y.%m.%d %H:%M:%S"`
|
||||
echo -e "*current time : ${datetime}\n" > ${file}
|
||||
cat ${origin} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__append (){
|
||||
line_count=`cat ${exec_log} | grep -v -- -- | egrep -v '(name|ri_count)' | wc -l`
|
||||
echo -e "\n${title} [${line_count}]\n" >> ${file}
|
||||
cat ${exec_log} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__query_exec (){
|
||||
steampipe query "${1}" > ${exec_log}
|
||||
__log_sed
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__log_sed (){
|
||||
sed -i 's/+/|/g' ${exec_log}
|
||||
sed -i "s/node-role.kubernetes.io\///g" ${exec_log}
|
||||
sed -i '1d;$d' ${exec_log}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
node_query="""
|
||||
SELECT
|
||||
name,
|
||||
annotations ->> 'projectcalico.org/IPv4Address' AS IP,
|
||||
COALESCE(taints -> 0 ->> 'key', '-') AS Taints_key,
|
||||
COALESCE(tags ->> 'kops.k8s.io/instancegroup', '-') AS Instance_group,
|
||||
capacity ->> 'cpu' AS CPU,
|
||||
CEIL((CAST(regexp_replace(capacity ->> 'memory', 'Ki', '') AS FLOAT) / 1024 / 1024)) AS Memory,
|
||||
tags ->> 'topology.kubernetes.io/zone' AS Zone,
|
||||
tags ->> 'beta.kubernetes.io/instance-type' AS Instance_type,
|
||||
node_info ->> 'osImage' AS OS,
|
||||
node_info ->> 'kubeletVersion' AS K8S_ver,
|
||||
node_info ->> 'containerRuntimeVersion' AS Runtime_ver
|
||||
FROM
|
||||
kubernetes_node
|
||||
ORDER BY
|
||||
Taints_key
|
||||
"""
|
||||
|
||||
resources_query="""
|
||||
(SELECT
|
||||
'sts' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
|
||||
FROM
|
||||
kubernetes_stateful_set
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'deploy' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_deployment
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'ds' as kind,
|
||||
name,
|
||||
number_available as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_daemonset
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
order by kind
|
||||
"""
|
||||
|
||||
service_query="""
|
||||
SELECT
|
||||
name,
|
||||
namespace,
|
||||
type,
|
||||
lower(p ->> 'nodePort') as Node_Port,
|
||||
age(current_timestamp, creation_timestamp)
|
||||
FROM
|
||||
kubernetes_service,
|
||||
jsonb_array_elements(ports) as p
|
||||
WHERE
|
||||
type='NodePort'
|
||||
ORDER BY
|
||||
Node_Port
|
||||
"""
|
||||
#name not like '%rel-%'
|
||||
|
||||
aws_ri_query="""
|
||||
SELECT
|
||||
COALESCE(a.availability_zone, b.availability_zone, '-') AS availability_zone,
|
||||
COALESCE(a.instance_type, b.instance_type, c.instance_type, '-') AS instance_type,
|
||||
COALESCE(c.cpu, 0) AS cpu,
|
||||
COALESCE(c.memory, 0) AS memory,
|
||||
COALESCE(a.ri_count, 0) AS ri_count,
|
||||
COALESCE(b.ec2_count, 0) AS ec2_count,
|
||||
COALESCE(b.ec2_count, 0) - COALESCE(a.ri_count, 0) AS result
|
||||
FROM
|
||||
(SELECT
|
||||
availability_zone,
|
||||
instance_type,
|
||||
SUM(instance_count) AS ri_count
|
||||
FROM
|
||||
aws_ec2_reserved_instance
|
||||
WHERE
|
||||
instance_state='active'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) a
|
||||
FULL OUTER JOIN
|
||||
(SELECT
|
||||
placement_availability_zone AS availability_zone,
|
||||
instance_type,
|
||||
COUNT(*) AS ec2_count
|
||||
FROM
|
||||
aws_ec2_instance
|
||||
WHERE
|
||||
instance_state='running' AND
|
||||
instance_lifecycle!='spot'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) b
|
||||
ON
|
||||
a.availability_zone = b.availability_zone AND
|
||||
a.instance_type = b.instance_type
|
||||
INNER JOIN
|
||||
(SELECT
|
||||
instance_type,
|
||||
(CAST(memory_info ->> 'SizeInMiB' AS FLOAT) / 1024) AS memory,
|
||||
(CAST(v_cpu_info ->> 'DefaultCores' AS FLOAT) * 2) AS cpu
|
||||
FROM
|
||||
aws_ec2_instance_type
|
||||
WHERE
|
||||
instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running')
|
||||
GROUP BY
|
||||
instance_type, memory, cpu
|
||||
) c
|
||||
ON
|
||||
COALESCE(a.instance_type, b.instance_type, '-') = c.instance_type
|
||||
ORDER BY availability_zone
|
||||
"""
|
||||
#instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running' AND instance_lifecycle!='spot')
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
origin="org_README.md"
|
||||
exec_log="/shared-data/query.log"
|
||||
file="/shared-data/README2.md"
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init
|
||||
|
||||
title="## 노드 목록"
|
||||
__query_exec "${node_query}"
|
||||
__append
|
||||
|
||||
title="## 리소스 목록"
|
||||
__query_exec "${resources_query}"
|
||||
__append
|
||||
|
||||
title="## 서비스 목록 (NodePort)"
|
||||
__query_exec "${service_query}"
|
||||
__append
|
||||
|
||||
title="## 예약 인스턴스 사용 내역"
|
||||
__query_exec "${aws_ri_query}"
|
||||
__append
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
rm ${exec_log}
|
||||
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: steampipe
|
||||
spec:
|
||||
containers:
|
||||
- name: steampipe
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: ["/bin/bash"]
|
||||
args: ["-c", "while true; do sleep 10; done"]
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Workflow
|
||||
metadata:
|
||||
generateName: scripts-bash-
|
||||
spec:
|
||||
entrypoint: bash-script-example
|
||||
volumes:
|
||||
- name: script-volume
|
||||
configMap:
|
||||
name: steampipe-script
|
||||
- name: kubeconfig
|
||||
secret:
|
||||
secretName: my-kubeconfig
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
templates:
|
||||
- name: bash-script-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: steampipe
|
||||
template: steampipe
|
||||
- name: git
|
||||
template: git
|
||||
dependencies:
|
||||
- steampipe
|
||||
|
||||
- name: steampipe
|
||||
script:
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: [bash]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
- name: kubeconfig
|
||||
mountPath: /kubeconfig
|
||||
env:
|
||||
- name: AWS_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: KMS_ARN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
- name: KUBECONFIG
|
||||
value: /kubeconfig/config
|
||||
source: |
|
||||
# 쿼리 결과를 공유 볼륨에 저장
|
||||
steampipe plugin install aws
|
||||
steampipe plugin install kubernetes
|
||||
sleep 1
|
||||
steampipe service restart --force
|
||||
sleep 1
|
||||
cd /shared-data/
|
||||
sleep 1
|
||||
bash /scripts/script.sh
|
||||
|
||||
- name: git
|
||||
script:
|
||||
image: alpine/git:latest
|
||||
command: [sh]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
env:
|
||||
- name: GIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: username
|
||||
- name: GIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: password
|
||||
source: |
|
||||
git config --global credential.helper 'store --file /tmp/credentials'
|
||||
echo "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com" > /tmp/credentials
|
||||
git config --global user.email "havelight@ex-em.com"
|
||||
git config --global user.name "jaehee-jung"
|
||||
cd /shared-data # 경로 내의 파일 목록 확인
|
||||
git clone https://github.com/CloudMOA/dsk-iac.git
|
||||
# 공유 볼륨에서 쿼리 결과 읽기
|
||||
cp README2.md dsk-iac/README.md
|
||||
# 커밋 및 푸시 작업 수행
|
||||
cd dsk-iac
|
||||
git add README.md
|
||||
git commit -m "Update README with query result"
|
||||
git push
|
||||
@@ -0,0 +1,143 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: steampipe-aws-report
|
||||
spec:
|
||||
schedule: "0 8 * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: bash-script-example
|
||||
volumes:
|
||||
- name: script-volume
|
||||
configMap:
|
||||
name: steampipe-script
|
||||
- name: kubeconfig
|
||||
secret:
|
||||
secretName: my-kubeconfig
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
templates:
|
||||
- name: bash-script-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: git-steampipe
|
||||
template: git-steampipe
|
||||
- name: steampipe
|
||||
template: steampipe
|
||||
dependencies:
|
||||
- git-steampipe
|
||||
- name: git-argo-workflows
|
||||
template: git-argo-workflows
|
||||
dependencies:
|
||||
- steampipe
|
||||
|
||||
- name: steampipe
|
||||
script:
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: [bash]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
- name: kubeconfig
|
||||
mountPath: /kubeconfig
|
||||
env:
|
||||
- name: AWS_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: KMS_ARN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
- name: KUBECONFIG
|
||||
value: /kubeconfig/config
|
||||
source: |
|
||||
# 쿼리 결과를 공유 볼륨에 저장
|
||||
steampipe plugin install aws
|
||||
sleep 3
|
||||
steampipe service restart --force
|
||||
sleep 1
|
||||
cd /shared-data/steampipe-mod-aws-compliance
|
||||
steampipe check benchmark.foundational_security --output=md > ../README.md
|
||||
sleep 1
|
||||
|
||||
- name: git-steampipe
|
||||
script:
|
||||
image: alpine/git:latest
|
||||
command: [sh]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
env:
|
||||
- name: GIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: username
|
||||
- name: GIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: password
|
||||
source: |
|
||||
cd /shared-data/
|
||||
git clone https://github.com/turbot/steampipe-mod-aws-compliance.git
|
||||
|
||||
- name: git-argo-workflows
|
||||
script:
|
||||
image: alpine/git:latest
|
||||
command: [sh]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
env:
|
||||
- name: GIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: username
|
||||
- name: GIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: password
|
||||
source: |
|
||||
cd /shared-data/
|
||||
git config --global credential.helper 'store --file /tmp/credentials'
|
||||
echo "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com" > /tmp/credentials
|
||||
git config --global user.email "havelight@ex-em.com"
|
||||
git config --global user.name "jaehee-jung"
|
||||
|
||||
git clone https://github.com/CloudMOA/argo-workflows.git
|
||||
# 공유 볼륨에서 쿼리 결과 읽기
|
||||
cp README.md argo-workflows/README.md
|
||||
# 커밋 및 푸시 작업 수행
|
||||
cd argo-workflows
|
||||
git add README.md
|
||||
git commit -m "Update README with query result"
|
||||
git push
|
||||
@@ -0,0 +1,200 @@
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
name: steampipe-script
|
||||
namespace: argo-workflows
|
||||
apiVersion: v1
|
||||
data:
|
||||
script.sh: |
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init (){
|
||||
touch ${origin}
|
||||
touch ${exec_log}
|
||||
datetime=`TZ='Asia/Seoul' date "+%Y.%m.%d %H:%M:%S"`
|
||||
echo -e "*update time : ${datetime}\n" > ${file}
|
||||
cat ${origin} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__append (){
|
||||
line_count=`cat ${exec_log} | grep -v -- -- | egrep -v '(name|ri_count)' | wc -l`
|
||||
echo -e "\n${title} [${line_count}]\n" >> ${file}
|
||||
cat ${exec_log} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__query_exec (){
|
||||
steampipe query "${1}" > ${exec_log}
|
||||
__log_sed
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__log_sed (){
|
||||
sed -i 's/+/|/g' ${exec_log}
|
||||
sed -i "s/node-role.kubernetes.io\///g" ${exec_log}
|
||||
sed -i '1d;$d' ${exec_log}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
node_query="""
|
||||
SELECT
|
||||
name,
|
||||
annotations ->> 'projectcalico.org/IPv4Address' AS IP,
|
||||
COALESCE(taints -> 0 ->> 'key', '-') AS Taints_key,
|
||||
COALESCE(tags ->> 'kops.k8s.io/instancegroup', '-') AS Instance_group,
|
||||
capacity ->> 'cpu' AS CPU,
|
||||
CEIL((CAST(regexp_replace(capacity ->> 'memory', 'Ki', '') AS FLOAT) / 1024 / 1024)) AS Memory,
|
||||
tags ->> 'topology.kubernetes.io/zone' AS Zone,
|
||||
tags ->> 'beta.kubernetes.io/instance-type' AS Instance_type,
|
||||
node_info ->> 'osImage' AS OS,
|
||||
node_info ->> 'kubeletVersion' AS K8S_ver,
|
||||
node_info ->> 'containerRuntimeVersion' AS Runtime_ver
|
||||
FROM
|
||||
kubernetes_node
|
||||
ORDER BY
|
||||
Taints_key
|
||||
"""
|
||||
|
||||
resources_query="""
|
||||
(SELECT
|
||||
'sts' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
|
||||
FROM
|
||||
kubernetes_stateful_set
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'deploy' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_deployment
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'ds' as kind,
|
||||
name,
|
||||
number_available as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_daemonset
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
order by kind
|
||||
"""
|
||||
|
||||
service_query="""
|
||||
SELECT
|
||||
name,
|
||||
namespace,
|
||||
type,
|
||||
lower(p ->> 'nodePort') as Node_Port,
|
||||
age(current_timestamp, creation_timestamp)
|
||||
FROM
|
||||
kubernetes_service,
|
||||
jsonb_array_elements(ports) as p
|
||||
WHERE
|
||||
type='NodePort'
|
||||
ORDER BY
|
||||
Node_Port
|
||||
"""
|
||||
#name not like '%rel-%'
|
||||
|
||||
aws_ri_query="""
|
||||
SELECT
|
||||
COALESCE(a.availability_zone, b.availability_zone, '-') AS availability_zone,
|
||||
COALESCE(a.instance_type, b.instance_type, c.instance_type, '-') AS instance_type,
|
||||
COALESCE(c.cpu, 0) AS cpu,
|
||||
COALESCE(c.memory, 0) AS memory,
|
||||
COALESCE(a.ri_count, 0) AS ri_count,
|
||||
COALESCE(b.ec2_count, 0) AS ec2_count,
|
||||
COALESCE(b.ec2_count, 0) - COALESCE(a.ri_count, 0) AS result
|
||||
FROM
|
||||
(SELECT
|
||||
availability_zone,
|
||||
instance_type,
|
||||
SUM(instance_count) AS ri_count
|
||||
FROM
|
||||
aws_ec2_reserved_instance
|
||||
WHERE
|
||||
instance_state='active'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) a
|
||||
FULL OUTER JOIN
|
||||
(SELECT
|
||||
placement_availability_zone AS availability_zone,
|
||||
instance_type,
|
||||
COUNT(*) AS ec2_count
|
||||
FROM
|
||||
aws_ec2_instance
|
||||
WHERE
|
||||
instance_state='running' AND
|
||||
instance_lifecycle!='spot'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) b
|
||||
ON
|
||||
a.availability_zone = b.availability_zone AND
|
||||
a.instance_type = b.instance_type
|
||||
INNER JOIN
|
||||
(SELECT
|
||||
instance_type,
|
||||
(CAST(memory_info ->> 'SizeInMiB' AS FLOAT) / 1024) AS memory,
|
||||
(CAST(v_cpu_info ->> 'DefaultCores' AS FLOAT) * 2) AS cpu
|
||||
FROM
|
||||
aws_ec2_instance_type
|
||||
WHERE
|
||||
instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running')
|
||||
GROUP BY
|
||||
instance_type, memory, cpu
|
||||
) c
|
||||
ON
|
||||
COALESCE(a.instance_type, b.instance_type, '-') = c.instance_type
|
||||
ORDER BY availability_zone
|
||||
"""
|
||||
#instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running' AND instance_lifecycle!='spot')
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
origin="/shared-data/org_README.md"
|
||||
exec_log="/shared-data/query.log"
|
||||
file="/shared-data/README2.md"
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init
|
||||
|
||||
title="## 노드 목록"
|
||||
__query_exec "${node_query}"
|
||||
__append
|
||||
|
||||
title="## 리소스 목록"
|
||||
__query_exec "${resources_query}"
|
||||
__append
|
||||
|
||||
title="## 서비스 목록 (NodePort)"
|
||||
__query_exec "${service_query}"
|
||||
__append
|
||||
|
||||
title="## 예약 인스턴스 사용 내역"
|
||||
__query_exec "${aws_ri_query}"
|
||||
__append
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
rm ${exec_log}
|
||||
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: steampipe
|
||||
spec:
|
||||
containers:
|
||||
- name: steampipe
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: ["/bin/bash"]
|
||||
args: ["-c", "while true; do sleep 10; done"]
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Workflow
|
||||
metadata:
|
||||
generateName: scripts-bash-
|
||||
spec:
|
||||
entrypoint: bash-script-example
|
||||
volumes:
|
||||
- name: script-volume
|
||||
configMap:
|
||||
name: steampipe-script
|
||||
- name: kubeconfig
|
||||
secret:
|
||||
secretName: my-kubeconfig
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
templates:
|
||||
- name: bash-script-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: steampipe
|
||||
template: steampipe
|
||||
- name: git
|
||||
template: git
|
||||
dependencies:
|
||||
- steampipe
|
||||
|
||||
- name: steampipe
|
||||
script:
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: [bash]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
- name: kubeconfig
|
||||
mountPath: /kubeconfig
|
||||
env:
|
||||
- name: AWS_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: KMS_ARN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
- name: KUBECONFIG
|
||||
value: /kubeconfig/config
|
||||
source: |
|
||||
# 쿼리 결과를 공유 볼륨에 저장
|
||||
steampipe plugin install aws
|
||||
steampipe plugin install kubernetes
|
||||
sleep 1
|
||||
steampipe service restart --force
|
||||
sleep 1
|
||||
cd /shared-data/
|
||||
sleep 1
|
||||
bash /scripts/script.sh
|
||||
|
||||
- name: git
|
||||
script:
|
||||
image: alpine/git:latest
|
||||
command: [sh]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
env:
|
||||
- name: GIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: username
|
||||
- name: GIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: password
|
||||
source: |
|
||||
git config --global credential.helper 'store --file /tmp/credentials'
|
||||
echo "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com" > /tmp/credentials
|
||||
git config --global user.email "havelight@ex-em.com"
|
||||
git config --global user.name "jaehee-jung"
|
||||
cd /shared-data # 경로 내의 파일 목록 확인
|
||||
git clone https://github.com/CloudMOA/dsk-iac.git
|
||||
# 공유 볼륨에서 쿼리 결과 읽기
|
||||
cp README2.md dsk-iac/README.md
|
||||
# 커밋 및 푸시 작업 수행
|
||||
cd dsk-iac
|
||||
git add README.md
|
||||
git commit -m "Update README with query result"
|
||||
git push
|
||||
115
helm/argo-workflows/Lab/steampipe-dsk-iac/cron-steampipe.yaml
Normal file
115
helm/argo-workflows/Lab/steampipe-dsk-iac/cron-steampipe.yaml
Normal file
@@ -0,0 +1,115 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: steampipe-iac-cron
|
||||
spec:
|
||||
schedule: "0 8 * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: bash-script-example
|
||||
volumes:
|
||||
- name: script-volume
|
||||
configMap:
|
||||
name: steampipe-script
|
||||
- name: kubeconfig
|
||||
secret:
|
||||
secretName: my-kubeconfig
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
|
||||
templates:
|
||||
- name: bash-script-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: steampipe
|
||||
template: steampipe
|
||||
- name: git
|
||||
template: git
|
||||
dependencies:
|
||||
- steampipe
|
||||
|
||||
- name: steampipe
|
||||
script:
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: [bash]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
- name: kubeconfig
|
||||
mountPath: /kubeconfig
|
||||
env:
|
||||
- name: AWS_REGION
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_REGION
|
||||
- name: AWS_ACCESS_KEY_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_ACCESS_KEY_ID
|
||||
- name: AWS_SECRET_ACCESS_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: AWS_SECRET_ACCESS_KEY
|
||||
- name: KMS_ARN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: aws-creds
|
||||
key: KMS_ARN
|
||||
- name: KUBECONFIG
|
||||
value: /kubeconfig/config
|
||||
source: |
|
||||
# 쿼리 결과를 공유 볼륨에 저장
|
||||
steampipe plugin install aws
|
||||
steampipe plugin install kubernetes
|
||||
sleep 3
|
||||
steampipe service restart --force
|
||||
sleep 1
|
||||
cd /shared-data/
|
||||
sleep 1
|
||||
bash /scripts/script.sh
|
||||
|
||||
- name: git
|
||||
script:
|
||||
image: alpine/git:latest
|
||||
command: [sh]
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: script-volume
|
||||
mountPath: /scripts
|
||||
env:
|
||||
- name: GIT_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: username
|
||||
- name: GIT_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: git-credentials
|
||||
key: password
|
||||
source: |
|
||||
git config --global credential.helper 'store --file /tmp/credentials'
|
||||
echo "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com" > /tmp/credentials
|
||||
git config --global user.email "havelight@ex-em.com"
|
||||
git config --global user.name "jaehee-jung"
|
||||
cd /shared-data # 경로 내의 파일 목록 확인
|
||||
git clone https://github.com/CloudMOA/dsk-iac.git
|
||||
# 공유 볼륨에서 쿼리 결과 읽기
|
||||
cp README2.md dsk-iac/README.md
|
||||
# 커밋 및 푸시 작업 수행
|
||||
cd dsk-iac
|
||||
git add README.md
|
||||
git commit -m "Update README with query result"
|
||||
git push
|
||||
@@ -0,0 +1,200 @@
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
name: steampipe-script
|
||||
namespace: argo-workflows
|
||||
apiVersion: v1
|
||||
data:
|
||||
script.sh: |
|
||||
#!/bin/bash
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init (){
|
||||
touch ${origin}
|
||||
touch ${exec_log}
|
||||
datetime=`TZ='Asia/Seoul' date "+%Y.%m.%d %H:%M:%S"`
|
||||
echo -e "*update time : ${datetime}\n" > ${file}
|
||||
cat ${origin} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__append (){
|
||||
line_count=`cat ${exec_log} | grep -v -- -- | egrep -v '(name|ri_count)' | wc -l`
|
||||
echo -e "\n${title} [${line_count}]\n" >> ${file}
|
||||
cat ${exec_log} >> ${file}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__query_exec (){
|
||||
steampipe query "${1}" > ${exec_log}
|
||||
__log_sed
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__log_sed (){
|
||||
sed -i 's/+/|/g' ${exec_log}
|
||||
sed -i "s/node-role.kubernetes.io\///g" ${exec_log}
|
||||
sed -i '1d;$d' ${exec_log}
|
||||
}
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
node_query="""
|
||||
SELECT
|
||||
name,
|
||||
annotations ->> 'projectcalico.org/IPv4Address' AS IP,
|
||||
COALESCE(taints -> 0 ->> 'key', '-') AS Taints_key,
|
||||
COALESCE(tags ->> 'kops.k8s.io/instancegroup', '-') AS Instance_group,
|
||||
capacity ->> 'cpu' AS CPU,
|
||||
CEIL((CAST(regexp_replace(capacity ->> 'memory', 'Ki', '') AS FLOAT) / 1024 / 1024)) AS Memory,
|
||||
tags ->> 'topology.kubernetes.io/zone' AS Zone,
|
||||
tags ->> 'beta.kubernetes.io/instance-type' AS Instance_type,
|
||||
node_info ->> 'osImage' AS OS,
|
||||
node_info ->> 'kubeletVersion' AS K8S_ver,
|
||||
node_info ->> 'containerRuntimeVersion' AS Runtime_ver
|
||||
FROM
|
||||
kubernetes_node
|
||||
ORDER BY
|
||||
Taints_key
|
||||
"""
|
||||
|
||||
resources_query="""
|
||||
(SELECT
|
||||
'sts' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
|
||||
FROM
|
||||
kubernetes_stateful_set
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'deploy' as kind,
|
||||
name,
|
||||
available_replicas as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_deployment
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
union
|
||||
(SELECT
|
||||
'ds' as kind,
|
||||
name,
|
||||
number_available as count,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'cpu' AS request_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'requests' ->> 'memory' AS request_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'cpu' AS limit_cpu,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') -> 'resources' -> 'limits' ->> 'memory' AS limit_mem,
|
||||
jsonb_array_elements(template -> 'spec' -> 'containers') ->> 'name' AS c_name,
|
||||
namespace
|
||||
FROM
|
||||
kubernetes_daemonset
|
||||
WHERE
|
||||
name not like 'rel-%')
|
||||
order by kind
|
||||
"""
|
||||
|
||||
service_query="""
|
||||
SELECT
|
||||
name,
|
||||
namespace,
|
||||
type,
|
||||
lower(p ->> 'nodePort') as Node_Port,
|
||||
age(current_timestamp, creation_timestamp)
|
||||
FROM
|
||||
kubernetes_service,
|
||||
jsonb_array_elements(ports) as p
|
||||
WHERE
|
||||
type='NodePort'
|
||||
ORDER BY
|
||||
Node_Port
|
||||
"""
|
||||
#name not like '%rel-%'
|
||||
|
||||
aws_ri_query="""
|
||||
SELECT
|
||||
COALESCE(a.availability_zone, b.availability_zone, '-') AS availability_zone,
|
||||
COALESCE(a.instance_type, b.instance_type, c.instance_type, '-') AS instance_type,
|
||||
COALESCE(c.cpu, 0) AS cpu,
|
||||
COALESCE(c.memory, 0) AS memory,
|
||||
COALESCE(a.ri_count, 0) AS ri_count,
|
||||
COALESCE(b.ec2_count, 0) AS ec2_count,
|
||||
COALESCE(b.ec2_count, 0) - COALESCE(a.ri_count, 0) AS result
|
||||
FROM
|
||||
(SELECT
|
||||
availability_zone,
|
||||
instance_type,
|
||||
SUM(instance_count) AS ri_count
|
||||
FROM
|
||||
aws_ec2_reserved_instance
|
||||
WHERE
|
||||
instance_state='active'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) a
|
||||
FULL OUTER JOIN
|
||||
(SELECT
|
||||
placement_availability_zone AS availability_zone,
|
||||
instance_type,
|
||||
COUNT(*) AS ec2_count
|
||||
FROM
|
||||
aws_ec2_instance
|
||||
WHERE
|
||||
instance_state='running' AND
|
||||
instance_lifecycle!='spot'
|
||||
GROUP BY
|
||||
availability_zone,
|
||||
instance_type
|
||||
) b
|
||||
ON
|
||||
a.availability_zone = b.availability_zone AND
|
||||
a.instance_type = b.instance_type
|
||||
INNER JOIN
|
||||
(SELECT
|
||||
instance_type,
|
||||
(CAST(memory_info ->> 'SizeInMiB' AS FLOAT) / 1024) AS memory,
|
||||
(CAST(v_cpu_info ->> 'DefaultCores' AS FLOAT) * 2) AS cpu
|
||||
FROM
|
||||
aws_ec2_instance_type
|
||||
WHERE
|
||||
instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running')
|
||||
GROUP BY
|
||||
instance_type, memory, cpu
|
||||
) c
|
||||
ON
|
||||
COALESCE(a.instance_type, b.instance_type, '-') = c.instance_type
|
||||
ORDER BY availability_zone
|
||||
"""
|
||||
#instance_type in (SELECT instance_type FROM aws_ec2_instance WHERE instance_state='running' AND instance_lifecycle!='spot')
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
origin="/shared-data/org_README.md"
|
||||
exec_log="/shared-data/query.log"
|
||||
file="/shared-data/README2.md"
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
__init
|
||||
|
||||
title="## 노드 목록"
|
||||
__query_exec "${node_query}"
|
||||
__append
|
||||
|
||||
title="## 리소스 목록"
|
||||
__query_exec "${resources_query}"
|
||||
__append
|
||||
|
||||
title="## 서비스 목록 (NodePort)"
|
||||
__query_exec "${service_query}"
|
||||
__append
|
||||
|
||||
title="## 예약 인스턴스 사용 내역"
|
||||
__query_exec "${aws_ri_query}"
|
||||
__append
|
||||
#------------------------------------------------------------------------------------------------------
|
||||
rm ${exec_log}
|
||||
34
helm/argo-workflows/Lab/steampipe.yaml
Normal file
34
helm/argo-workflows/Lab/steampipe.yaml
Normal file
@@ -0,0 +1,34 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Workflow
|
||||
metadata:
|
||||
generateName: scripts-bash-
|
||||
spec:
|
||||
entrypoint: bash-script-example
|
||||
templates:
|
||||
- name: bash-script-example
|
||||
steps:
|
||||
- - name: generate
|
||||
template: steampipe
|
||||
- - name: print
|
||||
template: print-message
|
||||
arguments:
|
||||
parameters:
|
||||
- name: message
|
||||
value: "{{steps.generate.outputs.result}}"
|
||||
|
||||
- name: steampipe
|
||||
script:
|
||||
image: ghcr.io/turbot/steampipe:latest
|
||||
command: [bash]
|
||||
source: |
|
||||
steampipe
|
||||
|
||||
- name: print-message
|
||||
inputs:
|
||||
parameters:
|
||||
- name: message
|
||||
container:
|
||||
image: alpine:latest
|
||||
command: [sh, -c]
|
||||
args: ["echo result was: {{inputs.parameters.message}}"]
|
||||
|
||||
6
helm/argo-workflows/Lab/test.sh
Normal file
6
helm/argo-workflows/Lab/test.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
GIT_USERNAME="jaehee-jung"
|
||||
GIT_PASSWORD="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"
|
||||
git config --global credential.helper 'store --file /etc/git/credentials'
|
||||
echo "https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com" > /etc/git/credentials
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: ui-monitoring-cron
|
||||
spec:
|
||||
schedule: "0 * * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: python-example
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: ui-monitoring
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
templates:
|
||||
- name: python-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: ui-monitoring
|
||||
template: ui-monitoring
|
||||
|
||||
- name: ui-monitoring
|
||||
container:
|
||||
image: nexus2.exem-oss.org/ui_monitoring:v0.6
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "======================================"
|
||||
python /tmp/dsk_playwright.py
|
||||
echo "======================================"
|
||||
echo -n "$SSH_KEY" > /tmp/id_rsa
|
||||
chmod 600 /tmp/id_rsa
|
||||
scp -i /tmp/id_rsa -o StrictHostKeyChecking=no -rp /shared-data/*_screenshot* root@10.10.43.98:/tmp/
|
||||
env:
|
||||
- name: SSH_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: bastion-ssh-key
|
||||
key: ssh-key
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
@@ -0,0 +1,37 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: ui-monitoring-cron
|
||||
spec:
|
||||
schedule: "0 * * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: python-example
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: ui-monitoring
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
templates:
|
||||
- name: python-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: ui-monitoring
|
||||
template: ui-monitoring
|
||||
|
||||
- name: ui-monitoring
|
||||
script:
|
||||
image: nexus2.exem-oss.org/ui_monitoring:v0.2
|
||||
volumeMounts:
|
||||
- name: shared-data
|
||||
mountPath: /shared-data
|
||||
- name: config-volume
|
||||
mountPath: /tmp/config.json
|
||||
subPath: config.json
|
||||
@@ -0,0 +1,62 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: CronWorkflow
|
||||
metadata:
|
||||
name: ui-monitoring-cron-test
|
||||
spec:
|
||||
schedule: "0 * * * *"
|
||||
timezone: "Asia/Seoul"
|
||||
workflowSpec:
|
||||
entrypoint: python-example
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: ui-monitoring
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: shared-data-{{workflow.name}}
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
templates:
|
||||
- name: python-example
|
||||
dag:
|
||||
tasks:
|
||||
- name: ui-monitoring
|
||||
template: ui-monitoring
|
||||
- name: move-capture
|
||||
template: scp
|
||||
dependencies:
|
||||
- ui-monitoring
|
||||
|
||||
- name: ui-monitoring
|
||||
script:
|
||||
image: nexus2.exem-oss.org/ui_monitoring:v0.3
|
||||
volumeMounts:
|
||||
- name: shared-data-{{workflow.name}}
|
||||
mountPath: /shared-data
|
||||
- name: config-volume
|
||||
mountPath: /tmp/config.json
|
||||
subPath: config.json
|
||||
|
||||
- name: scp
|
||||
container:
|
||||
image: nexus2.exem-oss.org/dsk-openssh-client:v1.0
|
||||
command: ["sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo -n "$SSH_KEY" > /tmp/id_rsa
|
||||
chmod 600 /tmp/id_rsa
|
||||
while true; do sleep 1; done
|
||||
scp -i /tmp/id_rsa -o StrictHostKeyChecking=no -rp /shared-data/*_screenshot* root@10.10.43.98:/tmp/
|
||||
scp -i /tmp/id_rsa -o StrictHostKeyChecking=no -rp /shared-data/*_error* root@10.10.43.98:/tmp/
|
||||
env:
|
||||
- name: SSH_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: bastion-ssh-key
|
||||
key: ssh-key
|
||||
volumeMounts:
|
||||
- name: shared-data-{{workflow.name}}
|
||||
mountPath: /shared-data
|
||||
@@ -0,0 +1,16 @@
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
annotations:
|
||||
name: ui-monitoring
|
||||
namespace: argo-workflows
|
||||
apiVersion: v1
|
||||
data:
|
||||
config.json: |
|
||||
{
|
||||
"dsk_url": "https://app.kr.datasaker.io",
|
||||
"dsk_username": "support@ex-em.com",
|
||||
"dsk_password": "saasadmin12#$",
|
||||
"slack_webhook_url" : "https://hooks.slack.com/services/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",
|
||||
"timeout": 10000
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user