ansible-collections / ansible-collections/google.cloud

kubectl_path of gcp_container_cluster omit field "server" in build

Open
#332 1 comment 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
105
Forks
144
Avg merge
5d 10h
Merged PRs (30d)
4

Description

##### SUMMARY

the compile result kubectl_path of gcp_container_cluster omit field "server" in "cluster" info.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
- gcp_container_cluster

##### ANSIBLE VERSION

```ansible 2.9.14
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 2 2020, 13:16:51) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

```

##### CONFIGURATION

##### OS / ENVIRONMENT

Linux 40cd0e14c615 5.8.11-200.fc32.x86_64 #1 SMP Wed Sep 23 13:51:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

##### STEPS TO REPRODUCE
```
---
- name: create a cluster
google.cloud.gcp_container_cluster:
name: my-cluster
initial_node_count: 2
master_auth:
username: cluster_admin
password: "{{ k8s_password }}"
node_config:
machine_type: n1-standard-1
disk_size_gb: 100
location: "{{ gcp_location }}"
project: "{{ gcp_project }}"
project: scctpr
#kubectl_path: "/root/.kube/config"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: my_cluster

```

##### EXPECTED RESULTS

```
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: XXXXX
server: https://XXX.YYY.ZZZ.WWW # <- omitted field
name: my-cluster
contexts:
- context: {cluster: my-cluster, user: my-cluster}
name: my-cluster
current-context: my-cluster
kind: Config
preferences: {}
users:
- name: my-cluster
user:
auth-provider:
config: {access-token: XXXXX,
cmd-args: config config-helper --format=json, cmd-path: /usr/lib64/google-cloud-sdk/bin/gcloud,
expiry-key: '{.credential.token_expiry}', token-key: '{.credential.access_token}'}
name: gcp
password: XXXXX
username: cluster_admin
```

##### ACTUAL RESULTS
```
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: {XXXXXXX}
name: my-cluster
contexts:
- context: {cluster: my-cluster, user: my-cluster}
name: my-cluster
current-context: my-cluster
kind: Config
preferences: {}
users:
- name: my-cluster
user:
auth-provider:
config: {access-token: XXXXXXX,
cmd-args: config config-helper --format=json, cmd-path: /usr/lib64/google-cloud-sdk/bin/gcloud,
expiry-key: '{.credential.token_expiry}', token-key: '{.credential.access_token}'}
name: gcp
password: XXXXXXXX
username: cluster_admin
```

The result does not show the URL (server field) of the cluster endpoint. thus preventing other modules, such as HELM (https://galaxy.ansible.com/community/kubernetes), from finding the cluster resources. Example:

```
TASK [Deploy ingress nginx] **********************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "command": "/usr/sbin/helm --kubeconfig /root/.kube/config --namespace=default list --output=yaml --filter nginx-controller", "msg": "Failure when executing Helm command. Exited 1.\nstdout: \nstderr: Error: Kubernetes cluster unreachable: Get \"http://localhost:8080/version?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused\n", "stderr": "Error: Kubernetes cluster unreachable: Get \"http://localhost:8080/version?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused\n", "stderr_lines": ["Error: Kubernetes cluster unreachable: Get \"http://localhost:8080/version?timeout=32s\": dial tcp 127.0.0.1:8080: connect: connection refused"], "stdout": "", "stdout_lines": []}
```

Contributor guide

Open the contributing guide

Research direction

Start with the google.cloud.gcp_container_cluster module and reproduce the supplied playbook, focusing on the generated kubeconfig written through kubectl_path. Compare the resulting cluster entry with the expected output and verify that the server endpoint is present so Helm can reach the cluster.

Written by the indexing model from the issue text.

Assessment

Tech stack
gcp, kubernetes, python
Domain
cloud, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.