Skip to content

Commit

Permalink
Merge pull request #22 from openinfradev/add_update_cluster_status_wftpl
Browse files Browse the repository at this point in the history
Add update cluster status wftpl
  • Loading branch information
zugwan authored Nov 3, 2021
2 parents 1957d5e + c519a1d commit 7f516c0
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 42 deletions.
8 changes: 4 additions & 4 deletions deploy_apps/tks-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
- name: revision
value: "main"
##########################
# For updateTksInfo task #
# For tks-info task #
##########################
- name: tks_info_host
value: "127.0.0.1"
Expand Down Expand Up @@ -50,16 +50,16 @@ spec:

- - name: updateTksInfo
templateRef:
name: update-tks-info
template: updateTksApp
name: update-tks-app-group-info
template: updateTksAppGroup
arguments:
parameters:
# TODO: Can this be pre-determined? Or composed dynamically on deployment?
- name: endpoints
value: "{'PROMETHEUS': 'thanos-sidecar.cluster_xy'}"
- name: app_group_status
value: "APP_GROUP_RUNNING"

# LMA appGroup specific task #
- - name: collectThanosScEndpoints
template: collectThanosScEndpoints
Expand Down
4 changes: 2 additions & 2 deletions deploy_apps/tks-remove-lma-federation-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
- name: site_repo_url
value: "https://github.com/openinfradev/decapod-site"
##########################
# For updateTksInfo task #
# For tks-info task #
##########################
- name: tks_info_host
value: "127.0.0.1"
Expand Down Expand Up @@ -47,7 +47,7 @@ spec:

- - name: updateTksInfo
templateRef:
name: update-tks-info
name: delete-tks-app-group-info
template: deleteTksAppGroup

# LMA appGroup specific task #
Expand Down
14 changes: 14 additions & 0 deletions tks-cluster/create-usercluster-wftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
value: "tks-admin"
- name: app_group
value: "tks-cluster"
- name: tks_info_host
value: "tks-info.tks.svc"

volumes:
- name: config
Expand All @@ -30,6 +32,9 @@ spec:
name: aws-artifacts
namespace: argo
defaultMode: 0555
- name: tks-proto-vol
configMap:
name: tks-proto

templates:
- name: deploy
Expand Down Expand Up @@ -64,6 +69,15 @@ spec:
{ "path": "kubernetes-addons", "namespace": "taco-system" }
]
- - name: update-cluster-status-to-running
templateRef:
name: update-tks-cluster-status
template: updateClusterStatus
arguments:
parameters:
- name: cluster_status
value: RUNNING

- name: wait-for-cluster-registration
activeDeadlineSeconds: 1800
container:
Expand Down
51 changes: 51 additions & 0 deletions tks_info/delete-tks-app-group-wftpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: delete-tks-app-group-info
namespace: argo
spec:
entrypoint: deleteTksAppGroup
arguments:
parameters:
- name: tks_info_host
value: "127.0.0.1"
- name: app_group_id
value: "abbead61-ff2a-4af4-8f41-d2c44c745de7"
volumes:
- name: tks-proto-vol
configMap:
name: tks-proto
templates:

- name: deleteTksAppGroup
inputs:
parameters:
script:
image: sktdev/python-centos-wf-worker:v1.0
command: ["python"]
env:
- name: PYTHONPATH
value: "/opt/protobuf/:/opt/rh/rh-python38/root/lib/python3.8/site-packages/:/opt/app-root/lib/python3.8/site-packages/"
volumeMounts:
- name: tks-proto-vol
mountPath: "/opt/protobuf"
readOnly: true
source: |
import sys
import google.protobuf
import grpc
import info_pb2
import info_pb2_grpc
import common_pb2
import common_pb2_grpc
ip = "{{workflow.parameters.tks_info_host}}"
port = 9110 # if not specified
addr = "%s:%d" % (ip, port)
print("tks-info addr: %s" % addr)
with grpc.insecure_channel(addr) as channel:
app_stub = info_pb2_grpc.AppInfoServiceStub(channel)
## TO-DO ##
res = app_stub.DeleteAppGroup(info_pb2.DeleteAppGroupRequest(app_group_id="{{workflow.parameters.app_group_id}}"))
print("Response code from DeleteAppGroup: %d" % res.code)
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: update-tks-info
name: update-tks-app-group-info
namespace: argo
spec:
entrypoint: updateTksApp
entrypoint: updateTksAppGroup
arguments:
parameters:
- name: tks_info_host
Expand All @@ -16,7 +16,7 @@ spec:
configMap:
name: tks-proto
templates:
- name: updateTksApp
- name: updateTksAppGroup
inputs:
parameters:
- name: endpoints # Dict type
Expand Down Expand Up @@ -55,36 +55,3 @@ spec:
for app_type_, ep in {{inputs.parameters.endpoints}}.items():
res = app_stub.UpdateApp(info_pb2.UpdateAppRequest(app_group_id="{{workflow.parameters.app_group_id}}", app_type=app_type_, endpoint=ep, metadata="{}"))
print("Response code from UpdateApp: %d" % res.code)
- name: deleteTksAppGroup
inputs:
parameters:
script:
image: sktdev/python-centos-wf-worker:v1.0
command: ["python"]
env:
- name: PYTHONPATH
value: "/opt/protobuf/:/opt/rh/rh-python38/root/lib/python3.8/site-packages/:/opt/app-root/lib/python3.8/site-packages/"
volumeMounts:
- name: tks-proto-vol
mountPath: "/opt/protobuf"
readOnly: true
source: |
import sys
import google.protobuf
import grpc
import info_pb2
import info_pb2_grpc
import common_pb2
import common_pb2_grpc
ip = "{{workflow.parameters.tks_info_host}}"
port = 9110 # if not specified
addr = "%s:%d" % (ip, port)
print("tks-info addr: %s" % addr)
with grpc.insecure_channel(addr) as channel:
app_stub = info_pb2_grpc.AppInfoServiceStub(channel)
## TO-DO ##
res = app_stub.DeleteAppGroup(info_pb2.DeleteAppGroupRequest(app_group_id="{{workflow.parameters.app_group_id}}"))
print("Response code from DeleteAppGroup: %d" % res.code)
64 changes: 64 additions & 0 deletions tks_info/update-tks-cluster-status-wftpl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: update-tks-cluster-status
namespace: argo
spec:
entrypoint: updateClusterStatus
arguments:
parameters:
- name: tks_info_host
value: "tks-info.tks.svc"
- name: cluster_id
value: "abbead61-ff2a-4af4-8f41-d2c44c745de7"
- name: cluster_status
value: UNSPECIFIED

volumes:
- name: tks-proto-vol
configMap:
name: tks-proto
templates:
- name: updateClusterStatus
inputs:
parameters:
- name: cluster_status
value: UNSPECIFIED
script:
image: sktdev/python-centos-wf-worker:v1.0
command: ["python"]
env:
- name: PYTHONPATH
value: "/opt/protobuf/:/opt/rh/rh-python38/root/lib/python3.8/site-packages/:/opt/app-root/lib/python3.8/site-packages/"
volumeMounts:
- name: tks-proto-vol
mountPath: "/opt/protobuf"
readOnly: true
source: |
import sys
import google.protobuf
import grpc
import info_pb2
import info_pb2_grpc
import common_pb2
import common_pb2_grpc
ip = "{{workflow.parameters.tks_info_host}}"
port = 9110 # if not specified
addr = "%s:%d" % (ip, port)
print("tks-info addr: %s" % addr)
with grpc.insecure_channel(addr) as channel:
stub = info_pb2_grpc.ClusterInfoServiceStub(channel)
res = stub.UpdateClusterStatus(info_pb2.UpdateClusterStatusRequest(cluster_id="{{workflow.parameters.cluster_id}}", status=common_pb2.{{inputs.parameters.cluster_status}}))
print("Response code from UpdateClusterStaus: %d" % res.code)
- name: runUpdateClusterStatus
steps:
- - name: runUpdateClusterStatus
template: updateClusterStatus
arguments:
parameters:
- name: cluster_status
value: "{{workflow.parameters.cluster_status}}"

0 comments on commit 7f516c0

Please sign in to comment.