Closed dirien closed 3 years ago
@dirien As a workaround, have you tried changing the destination path of the parameter like so? Porter will inject the last value of the kubeconfig output from previous porter runs into whatever path you choose.
parameters:
- name: kubeconfig
path: /root/.kube/config
source:
output: kubeconfig
I agree that the mixin should support changing the location, just trying to get you unblocked. 😀
Also I wanted to make sure that you intended to use the helm v2 mixin? In case you are actually using the helm v3 mixin, that repository is located at https://github.com/MChorfa/porter-helm3.
Hi @carolynvs,
unfortunatly it still not working...
as you see the terrafrom mixin is creating the output:
BTW: Thanks for the helm3 hint... I just followed the mixin list on https://porter.sh/mixins/helm/
Can you provide the entire porter.yaml? I just double checked what I suggested locally and was able to get it to work. Maybe I can help spot the problem.
of course @carolynvs ,
# This is the configuration for Porter
# You must define steps for each action, but the rest is optional
# See https://porter.sh/author-bundles for documentation on how to configure your bundle
# Uncomment out the sections below to take full advantage of what Porter can do!
name: porter-civo-kubernetes
version: 0.1.0
description: "Building a porter bundle for civo"
registry: getporter
mixins:
- terraform:
clientVersion: 1.0.1
- kubernetes
- helm3:
repositories:
prometheus-community:
url: "https://prometheus-community.github.io/helm-charts"
credentials:
- name: token
env: CIVO_TOKEN
parameters:
- name: name
type: string
default: "civo-porter-cluster"
- name: tfstate
type: file
path: /cnab/app/terraform/terraform.tfstate
source:
output: tfstate
- name: kubeconfig
path: /root/.kube/config
source:
output: kubeconfig
outputs:
- name: tfstate
type: file
path: /cnab/app/terraform/terraform.tfstate
- name: kubeconfig
type: file
path: /root/.kube/config
install:
- terraform:
description: "Create Civo Kubernetes Cluster"
input: false
backendConfig:
key: "{{ bundle.name }}.tfstate"
vars:
token: "{{bundle.credentials.token}}"
name: "{{bundle.parameters.name}}"
outputs:
- name: kubeconfig
- helm3:
description: "Install the kube-prometheus-stack"
name: "kube-prometheus-stack"
chart: prometheus-community/kube-prometheus-stack
version: 16.11.0
namespace: "kube-prometheus-stack"
replace: true
uninstall:
- terraform:
description: "Delete Civo Kubernetes Cluster"
input: false
backendConfig:
key: "{{ bundle.name }}.tfstate"
vars:
token: "{{bundle.credentials.token}}"
name: "{{bundle.parameters.name}}"
Here try this updated file with two changes, to both the kubeconfig param and output.
# This is the configuration for Porter
# You must define steps for each action, but the rest is optional
# See https://porter.sh/author-bundles for documentation on how to configure your bundle
# Uncomment out the sections below to take full advantage of what Porter can do!
name: porter-civo-kubernetes
version: 0.1.0
description: "Building a porter bundle for civo"
registry: getporter
mixins:
- terraform:
clientVersion: 1.0.1
- kubernetes
- helm3:
repositories:
prometheus-community:
url: "https://prometheus-community.github.io/helm-charts"
credentials:
- name: token
env: CIVO_TOKEN
parameters:
- name: name
type: string
default: "civo-porter-cluster"
- name: tfstate
type: file
path: /cnab/app/terraform/terraform.tfstate
source:
output: tfstate
- name: kubeconfig
type: file # Set the parameter type, affects how the parameter is encoded.
path: /root/.kube/config
source:
output: kubeconfig
outputs:
- name: tfstate
type: file
path: /cnab/app/terraform/terraform.tfstate
- name: kubeconfig
type: file
# omit the path so that the kubeconfig file captured in the first install step is used. Otherwise porter looks for it at the specified path (which doesn't exist)
install:
- terraform:
description: "Create Civo Kubernetes Cluster"
input: false
backendConfig:
key: "{{ bundle.name }}.tfstate"
vars:
token: "{{bundle.credentials.token}}"
name: "{{bundle.parameters.name}}"
outputs:
- name: kubeconfig
- helm3:
description: "Install the kube-prometheus-stack"
name: "kube-prometheus-stack"
chart: prometheus-community/kube-prometheus-stack
version: 16.11.0
namespace: "kube-prometheus-stack"
replace: true
uninstall:
- terraform:
description: "Delete Civo Kubernetes Cluster"
input: false
backendConfig:
key: "{{ bundle.name }}.tfstate"
vars:
token: "{{bundle.credentials.token}}"
name: "{{bundle.parameters.name}}"
I think i got the issue. Its my fault. I thought that:
outputs:
- name: kubeconfig
type: file
That the output will get saved straight into a file. That was wrong assumed from me.
Thanks for your help @carolynvs !
Happy to help! I've started a new topic in our forum to feel out how we can make this configuration more straightforward. So please check it out and let us know if it seems like an improvement or needs more work.
Hi Porter team,
I am trying to build a bundle, where i create via terraform a kubernetes bundle. The output
kubeconfig
i try to safe:and in paramter i try to reference to it:
But somehow, this is not working as the Kubernetes client expects the kubeconfig here:
https://github.com/getporter/helm-mixin/blob/02defaa76335fede1725a764122bc9e1fb0c4e6a/pkg/helm/install.go#L40
Am i doing something wrong maybe? Is there a different way, to use the output of terrafrom as an input for the next mixin?