Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom program sources #741

Merged
merged 2 commits into from
Nov 5, 2024
Merged

Support for custom program sources #741

merged 2 commits into from
Nov 5, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Nov 5, 2024

Proposed changes

This PR relaxes a constraint on the Stack resource to allow a stack without any "source" information - Git, Flux, Program object - with the expectation that the user will provide the Pulumi project files by other means. One way is to bake the files into the Workspace's own docker image, by extending pulumi/pulumi:latest. Another way is to inject an init container that copies files to /share/workspace.

To make it easy to use the Docker image way, the Workspace spec has a new local.dir element to specify the location of the baked-in Pulumi project. In that case, the system creates a symlink from /share/workspace to the specified directory. This approach is similar to how the built-in sources work; the repo is cloned to /share/source and then symlinked. For example:

apiVersion: pulumi.com/v1
kind: Stack
metadata:
  name: custom-source
  namespace: default
spec:
  ...
  workspaceTemplate:
    spec:
      image: localhost:5000/pulumi-and-app:latest
      imagePullPolicy: IfNotPresent
      local:
        dir: /home/pulumi/examples/stack-readme-py

In the workspace pod, this causes an extra init container to be injected:

kind: Pod
spec:
  initContainers:
  - args:
    - sh
    - -c
    - ln -s $LOCAL_DIR /share/workspace
    env:
    - name: LOCAL_DIR
      value: /home/pulumi/examples/stack-readme-py
    image: pulumi/pulumi-kubernetes-operator:v2.0.0-beta.1
    imagePullPolicy: IfNotPresent
    name: fetch

An example program is also provided explaining to users how to use this functionality.

Related issues (optional)

Closes #730

@EronWright EronWright requested a review from blampe November 5, 2024 23:33
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

Attention: Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.

Project coverage is 50.28%. Comparing base (cfb8e3c) to head (3075c83).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
operator/internal/apply/utils.go 0.00% 2 Missing ⚠️
...tor/internal/controller/pulumi/stack_controller.go 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #741      +/-   ##
==========================================
+ Coverage   50.01%   50.28%   +0.26%     
==========================================
  Files          30       30              
  Lines        4061     4091      +30     
==========================================
+ Hits         2031     2057      +26     
- Misses       1846     1850       +4     
  Partials      184      184              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EronWright EronWright merged commit 0b5b8e4 into master Nov 5, 2024
7 checks passed
@EronWright EronWright deleted the issue-730 branch November 5, 2024 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make source be optional
2 participants