silly-match-22314
07/20/2023, 1:28 PMclass PulumiProgram:
def __init__(self):
self._work_dir = os.path.join(os.path.dirname(__file__))
self._data = self._load_config_file('defaults.yaml')
self._stack = auto.create_or_select_stack('dev', project_name='test-eks', work_dir=self._work_dir,
program=self._create_resources())
self._stack.set_config('aws:region', auto.ConfigValue('us-east-1'))
self._stack.set_config('values', auto.ConfigValue(json.dumps(self._data.get('values'))))
def preview(self):
self._stack.refresh(on_output=print)
self._stack.preview(on_output=print)
def up(self):
self._stack.refresh(on_output=print)
self._stack.up(on_output=print)
def _load_config_file(self, path: str):
with open(path, "r") as f:
data = yaml.full_load(f)
return data
def _create_resources(self):
chart_values = self._data.get('values')
kube = open("/Users/nathanell/.kube/lab-okta-playground-eks").read()
k8s_provider = k8s.Provider(resource_name="k8s-provider", kubeconfig=pulumi.Output.secret(kube))
ui_app_chart = Release(
"ui-app-micro-fe",
ReleaseArgs(
name='nginx-test-nati',
chart="../helm",
values=chart_values,
namespace=f'{chart_values.get("project")}-{chart_values.get("app")}',
create_namespace=True,
version='1.0.0'
),
opts=ResourceOptions(provider=k8s_provider)
)
if __name__ == "__main__":
PulumiProgram().up()
While the same code is working for me while using Pulumi CLI program:
config = pulumi.Config()
chart_values = json.loads(config.get('values'))
kube = open("/Users/nathanell/.kube/lab-okta-playground-eks").read()
provider = k8s.Provider(resource_name="k8s-provider", kubeconfig=pulumi.Output.secret(kube))
print(chart_values)
nginx_chart = Release(
"nginx-ingress",
ReleaseArgs(
name='nginx-test-nati',
chart="../helm",
values=chart_values,
namespace=f'{chart_values.get("project")}-{chart_values.get("app")}',
create_namespace=True,
version='1.0.0'
),
opts=ResourceOptions(provider=provider)
)
This is the error that I'm getting:
kubernetes:core/v1:Namespace (ui-app-nginx):
error: configured Kubernetes cluster is unreachable: unable to load schema information from the API server: the server has asked for the client to provide credentials
Although I have verified that the kubeconfig is ok and working in the pulumi CLI program
Someone can assist?echoing-dinner-19531
07/21/2023, 3:15 PMself._create_resources()
I think that should be self._create_resources
, you want a reference to the function there, not to call it.silly-match-22314
07/22/2023, 8:04 PMsilly-match-22314
07/22/2023, 8:16 PMechoing-dinner-19531
07/23/2023, 10:54 AMsilly-match-22314
07/23/2023, 10:55 AMechoing-dinner-19531
07/23/2023, 11:50 AMBTW, do you know how to get a kubeconfig content from pulumi w/o creating an actual file?As in from aws clusters and the like? Or creating them in code? The former I'm pretty sure things like eks cluster resources have a kubeconfig property on them. The later, there's nothing built-in really but it's just building up a json file which should be pretty simple in most languages.
silly-match-22314
07/30/2023, 2:55 PM