Skip to content

Commit

Permalink
Adapter deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveengostu committed Sep 16, 2022
2 parents 7b815b4 + 135ebc7 commit 5fe42d2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
39 changes: 22 additions & 17 deletions templates/service/runtime-ansible-job.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ resource "kubernetes_config_map" "runtime_ansible_job_configmap" {
ANSIBLE_JOB_OPPONENTSCA = ""
#ANSIBLE_JOB_CERTPEM = ""
#ANSIBLE_JOB_KEYPEM = ""
ADAPTER_HTTPPORT = "4001"
ADAPTER_MAXRETRIES = ""
ADAPTER_LOCATION = "us-south"
ADAPTER_LOGGERLEVEL = "-1"
ADAPTER_ATLOGGERLEVEL = "-1"
ADAPTER_EXTLOGGERLEVEL = "-1"
ADAPTER_EXTLOGPATH = "/var/log/schematics/%s.log"
ADAPTER_PLUGINHOME = "/go/src/github.ibm.com/blueprint/schematics-data-adapter/plugins"
}

depends_on = [kubernetes_namespace.namespace]
Expand All @@ -80,7 +72,7 @@ resource "kubernetes_config_map" "runtime_ansible_job_configmap" {

resource "kubernetes_config_map" "runtime_adapter_job_configmap" {
metadata {
name = "schematics-runtime-ansible-job-config"
name = "schematics-runtime-adapter-job-config"
namespace = "schematics-runtime"
}

Expand Down Expand Up @@ -122,6 +114,25 @@ resource "kubernetes_service" "ansible_job_service" {
depends_on = [kubernetes_namespace.namespace]
}

//creating image pull secret for job
resource "kubernetes_secret" "schematics-ansible-secret" {
metadata {
name = "schematics-runtime-ansible-job-image-secret"
namespace = "schematics-runtime"
}
data = {
".dockerconfigjson" = jsonencode({
auths = {
"us.icr.io" = {
auth = base64encode("iamapikey:${var.ansible_pull_ibmcloud_api_key}")
}
}
})
}
type = "kubernetes.io/dockerconfigjson"
depends_on = [kubernetes_namespace.namespace]
}


resource "kubernetes_deployment" "runtime_ansible_job" {
timeouts {
Expand Down Expand Up @@ -155,7 +166,6 @@ resource "kubernetes_deployment" "runtime_ansible_job" {
metadata {
labels = {
app = "runtime-ansible-job"

build = "ansible-job-1338"
}
}
Expand Down Expand Up @@ -200,13 +210,12 @@ resource "kubernetes_deployment" "runtime_ansible_job" {
}

image_pull_secrets {
name = "schematics-runtime-job-image-secret"
name = "schematics-runtime-ansible-job-image-secret"
}

container {
name = "runtime-job"
image = local.schematics_runtime_ansible_job_image

port {
name = "grpc-job"
container_port = 3002
Expand Down Expand Up @@ -254,10 +263,9 @@ resource "kubernetes_deployment" "runtime_ansible_job" {
run_as_non_root = true
}
}

container {
name = "adapter"
image = "us.icr.io/$${CR_NAMESPACE}/schematics-data-adapter:$${ADAPTER_IMAGE_TAG}"
image = local.schematics_runtime_adapter_job_image

env_from {
config_map_ref {
Expand Down Expand Up @@ -296,7 +304,6 @@ resource "kubernetes_deployment" "runtime_ansible_job" {
termination_grace_period_seconds = 180000
}
}

strategy {
type = "RollingUpdate"

Expand All @@ -312,6 +319,4 @@ resource "kubernetes_deployment" "runtime_ansible_job" {
depends_on = [kubernetes_service.job_service, kubernetes_config_map.runtime_ansible_job_configmap,kubernetes_config_map.runtime_adapter_job_configmap, kubernetes_namespace.namespace]
}



##############################################################################
8 changes: 8 additions & 0 deletions templates/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ variable "ibmcloud_api_key" {
default = ""
}


variable "ansible_pull_ibmcloud_api_key" {
description = "The IBM Cloud API Key used to pull ansible images"
type = string
sensitive = true
default = ""
}

##############################################################################

0 comments on commit 5fe42d2

Please sign in to comment.