This repository was archived by the owner on Aug 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +65
-1
lines changed Expand file tree Collapse file tree 4 files changed +65
-1
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
2+
3+ BIN_DIR=$( cat .bin_dir)
4+
5+ export PATH=" ${BIN_DIR} :${PATH} "
6+
7+ CLUSTER_CRED=$( cat .cluster_creds)
8+
9+ SERVER_URL=$( echo " ${CLUSTER_CRED} " | jq -r ' .server_url' )
10+ USERNAME=$( echo " ${CLUSTER_CRED} " | jq -r ' .username' )
11+ PASSWORD=$( echo " ${CLUSTER_CRED} " | jq -r ' .password' )
12+ TOKEN=$( echo " ${CLUSTER_CRED} " | jq -r ' .token' )
13+
14+ if [[ -n " ${TOKEN} " ]]; then
15+ echo " Logging into OpenShift cluster ${SERVER_URL} as token"
16+ oc login " ${SERVER_URL} " --token " ${TOKEN} "
17+ else
18+ echo " Logging into OpenShift cluster ${SERVER_URL} as user ${USERNAME} "
19+ oc login " ${SERVER_URL} " --username " ${USERNAME} " --password " ${PASSWORD} "
20+ fi
Original file line number Diff line number Diff line change @@ -59,3 +59,25 @@ output "workers" {
5959 value = local. workers
6060 depends_on = [data . ibm_container_vpc_cluster_worker . workers ]
6161}
62+
63+ output "server_url" {
64+ description = " The url used to connect to the api server. If the cluster has public endpoints enabled this will be the public api server, otherwise this will be the private api server url"
65+ value = data. ibm_container_vpc_cluster . config . public_service_endpoint ? data. ibm_container_vpc_cluster . config . public_service_endpoint_url : data. ibm_container_vpc_cluster . config . private_service_endpoint_url
66+ }
67+
68+ output "username" {
69+ description = " The username of the admin user for the cluster"
70+ value = " apikey"
71+ }
72+
73+ output "password" {
74+ description = " The password of the admin user for the cluster"
75+ value = var. ibmcloud_api_key
76+ sensitive = true
77+ }
78+
79+ output "token" {
80+ description = " The admin user token used to generate the cluster"
81+ value = " "
82+ sensitive = true
83+ }
Original file line number Diff line number Diff line change 11terraform {
2- required_version = " >= 0.13 .0"
2+ required_version = " >= 0.15 .0"
33
44 required_providers {
55 ibm = {
66 source = " ibm-cloud/ibm"
77 }
88 }
99}
10+
11+ module setup_clis {
12+ source = " github.com/cloud-native-toolkit/terraform-util-clis.git"
13+
14+ bin_dir = " ${ path . cwd } /test_bin_dir"
15+ clis = [" jq" , " oc" ]
16+ }
17+
18+ resource local_file bin_dir {
19+ filename = " ${ path . cwd } /.bin_dir"
20+
21+ content = module. setup_clis . bin_dir
22+ }
Original file line number Diff line number Diff line change @@ -14,3 +14,13 @@ module "cluster" {
1414 vpc_subnet_count = module. subnets . count
1515 cos_id = module. cos . id
1616}
17+
18+ resource "local_file" "cluster_creds" {
19+ filename = " .cluster_creds"
20+ content = jsonencode ({
21+ server_url = module.cluster.server_url
22+ username = module.cluster.username
23+ password = module.cluster.password
24+ token = module.cluster.token
25+ })
26+ }
You can’t perform that action at this time.
0 commit comments