-
Notifications
You must be signed in to change notification settings - Fork 6
enable SSL for the SDK pod #285
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
Merged
laverya
merged 49 commits into
main
from
laverya/sc-123955/enable-ssl-for-replicated-sdk-pod
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
18d5436
initial TLS attempt
laverya 061f307
remove broken 'make build-ttl.sh' command
laverya a4b2dbe
Update chart/values.yaml
laverya a506ba3
automatically set http/https status probe
laverya 0d8e7f3
undo makefile change
laverya 315c3a6
reinclude build-ttl.sh
laverya 9e8d950
print image/chart locations in validate
laverya 0c88660
new dagger command
laverya 40cd6e8
f
laverya 88c18ed
exit logging
laverya 0efb1b9
more validation logging
laverya 801f980
undo test chart related changes
laverya 2d66114
wait 15 minutes
laverya be8f9a7
remove redundant logs
laverya b0732e2
add TLS testing
laverya 97cde54
Merge remote-tracking branch 'origin/main' into laverya/sc-123955/ena…
laverya 540d510
login to registry
laverya fa02e5a
add success log
laverya 789e092
remove unneeded param from test-chart call
laverya 79aab5e
fix the build ttl.sh call by making it call dagger instead
laverya 7cade08
push wrapped chart in ttl.sh build, print destination
laverya 5cf89b7
set the right helm value?
laverya cdfe05c
ensure that the SDK pod is actually serving TLS traffic after update
laverya 7314277
yaml...
laverya 847b7ec
fix deployment yaml
laverya 12dd2ab
apply why?
laverya 37daba1
logs?
laverya 5449a86
bad deployment yaml test
laverya 2eba412
stderr?
laverya ccf04d8
yaml formatting and logging
laverya 07e1cd5
print deployment description after timeout
laverya 7a6e6b3
check if replicated deployment is using https health check
laverya 23f4e76
delete old pod before waiting for new one
laverya d82161f
dir?
laverya 6e9dade
logs and secrets
laverya 3371f3a
tls cert creation error checking
laverya 134e0b7
pass certs properly?
laverya d884c7d
different type
laverya 178c362
fix file path
laverya db11141
correct filepath fix?
laverya cf45f57
secret create command
laverya 921765b
secret create logging
laverya 8e08608
run ci again
laverya 02303e6
check if a file not existing results in logs
laverya c927b2f
chmod +r cert files, only run openshift test
laverya 20ccef9
F
laverya f38d860
final pod logging
laverya 0ce091c
enable parallel tests again
laverya 98c8d46
remove redundant pod deletion
laverya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ func e2e( | |
|
||
out, err := ctr.Stdout(ctx) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to create cluster: %w", err) | ||
} | ||
|
||
type ReplicatedCluster struct { | ||
|
@@ -35,7 +35,7 @@ func e2e( | |
} | ||
replicatedCluster := ReplicatedCluster{} | ||
if err := json.Unmarshal([]byte(out), &replicatedCluster); err != nil { | ||
return err | ||
return fmt.Errorf("failed to unmarshal cluster: %w", err) | ||
} | ||
|
||
// get the kubeconfig | ||
|
@@ -45,7 +45,7 @@ func e2e( | |
|
||
kubeconfig, err := ctr.Stdout(ctx) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to get kubeconfig: %w", err) | ||
} | ||
|
||
kubeconfigSource := source.WithNewFile("/kubeconfig", kubeconfig) | ||
|
@@ -57,7 +57,7 @@ func e2e( | |
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to install chart: %w", err) | ||
} | ||
|
||
fmt.Println(out) | ||
|
@@ -76,6 +76,7 @@ func e2e( | |
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
fmt.Printf("failed to wait for deployment to be ready: %v\n", err) | ||
// return err | ||
} | ||
|
||
|
@@ -91,7 +92,7 @@ func e2e( | |
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to get namespaces: %w", err) | ||
} | ||
|
||
fmt.Println(out) | ||
|
@@ -106,10 +107,174 @@ func e2e( | |
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return err | ||
return fmt.Errorf("failed to get pods: %w", err) | ||
} | ||
|
||
fmt.Println(out) | ||
|
||
// create a tls cert and key | ||
certDir := dag.Container().From("alpine/openssl:latest"). | ||
WithWorkdir("/certs"). | ||
WithExec([]string{"openssl", "req", "-x509", "-newkey", "rsa:4096", "-keyout", "/certs/test-key.key", "-out", "/certs/test-cert.crt", "-days", "365", "-nodes", "-subj", "/CN=test.com"}). | ||
WithExec([]string{"chmod", "+r", "/certs/test-cert.crt"}). | ||
WithExec([]string{"chmod", "+r", "/certs/test-key.key"}). | ||
Directory("/certs") | ||
|
||
// create a TLS secret within the namespace | ||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithFile("/certs/test-cert.crt", certDir.File("/test-cert.crt")). | ||
WithFile("/certs/test-key.key", certDir.File("/test-key.key")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec( | ||
[]string{ | ||
"kubectl", "create", "secret", "tls", "test-tls", "--cert=/certs/test-cert.crt", "--key=/certs/test-key.key", | ||
}) | ||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
stderr, _ := ctr.Stderr(ctx) | ||
return fmt.Errorf("failed to create tls secret: %w\n\nStderr: %s\n\nStdout: %s", err, stderr, out) | ||
} | ||
fmt.Println(out) | ||
|
||
// update the chart to set TLS to true | ||
ctr = dag.Container().From("alpine/helm:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithExec([]string{"helm", "registry", "login", "registry.replicated.com", "--username", "[email protected]", "--password", licenseID}). | ||
WithExec([]string{"helm", "upgrade", "test-chart", fmt.Sprintf("oci://registry.replicated.com/replicated-sdk-e2e/%s/test-chart", channelSlug), "--version", "0.1.0", "--set", "replicated.tlsCertSecretName=test-tls"}) | ||
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return fmt.Errorf("failed to upgrade chart enabling TLS: %w", err) | ||
} | ||
fmt.Println(out) | ||
|
||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec( | ||
[]string{ | ||
"kubectl", "get", "secrets", | ||
}) | ||
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return fmt.Errorf("failed to get secrets: %w", err) | ||
} | ||
|
||
fmt.Println(out) | ||
|
||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec( | ||
[]string{ | ||
"kubectl", "get", "pods", | ||
}) | ||
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return fmt.Errorf("failed to get pods: %w", err) | ||
} | ||
|
||
fmt.Println(out) | ||
|
||
// wait for the pod to be ready | ||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec( | ||
[]string{ | ||
"kubectl", "wait", | ||
"--for=condition=available", | ||
"deployment/replicated", | ||
"--timeout=1m", | ||
}) | ||
|
||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
fmt.Printf("failed to wait for deployment to be ready after enabling TLS: %v\n", err) | ||
// return err | ||
} | ||
fmt.Println(out) | ||
|
||
// create a kubernetes deployment that runs a pod - the pod has a readiness probe that runs 'curl -k https://replicated.svc:3000/health' | ||
// this will only pass if the replicated pod is ready and serving TLS traffic | ||
deploymentYaml := `apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: replicated-ssl-test | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: replicated-ssl-test | ||
template: | ||
metadata: | ||
labels: | ||
app: replicated-ssl-test | ||
spec: | ||
containers: | ||
- name: replicated-ssl-test | ||
image: alpine/curl:latest | ||
command: ["sleep", "500d"] | ||
ports: | ||
- containerPort: 3000 | ||
readinessProbe: | ||
exec: | ||
command: ["curl", "-k", "https://replicated:3000/health"] | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10` | ||
deploymentSource := source.WithNewFile("/replicated-ssl-test.yaml", deploymentYaml) | ||
|
||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithFile("/root/replicated-ssl-test.yaml", deploymentSource.File("/replicated-ssl-test.yaml")). | ||
WithExec([]string{"kubectl", "apply", "-f", "/root/replicated-ssl-test.yaml"}) | ||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
// Get stderr to see the actual error | ||
stderr, _ := ctr.Stderr(ctx) | ||
return fmt.Errorf("failed to apply replicated-ssl-test deployment: %w\n\nStderr: %s\n\nStdout: %s", err, stderr, out) | ||
} | ||
fmt.Println(out) | ||
|
||
// wait for the replicated-ssl-test deployment to be ready | ||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec([]string{"kubectl", "wait", "--for=condition=available", "deployment/replicated-ssl-test", "--timeout=1m"}) | ||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec([]string{"kubectl", "logs", "-p", "-l", "app.kubernetes.io/name=replicated"}) | ||
out, err2 := ctr.Stdout(ctx) | ||
if err2 != nil { | ||
return fmt.Errorf("failed to get logs for replicated deployment: %w", err2) | ||
} | ||
fmt.Println(out) | ||
|
||
return fmt.Errorf("failed to wait for replicated deployment to be ready: %w", err) | ||
} | ||
fmt.Println(out) | ||
|
||
// print the final pods | ||
ctr = dag.Container().From("bitnami/kubectl:latest"). | ||
WithFile("/root/.kube/config", kubeconfigSource.File("/kubeconfig")). | ||
WithEnvVariable("KUBECONFIG", "/root/.kube/config"). | ||
WithExec( | ||
[]string{ | ||
"kubectl", "get", "pods", "-n", "default", | ||
}) | ||
out, err = ctr.Stdout(ctx) | ||
if err != nil { | ||
return fmt.Errorf("failed to get pods: %w", err) | ||
} | ||
fmt.Println(out) | ||
|
||
fmt.Printf("E2E test for distribution %s and version %s passed\n", distribution, version) | ||
return nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"dagger/replicated-sdk/internal/dagger" | ||
"fmt" | ||
"time" | ||
) | ||
|
||
// TestChart builds the SDK image and chart and wraps them in a test chart | ||
func (m *ReplicatedSdk) TestChart( | ||
ctx context.Context, | ||
|
||
// +defaultPath="/" | ||
source *dagger.Directory, | ||
) error { | ||
imageRegistry, imageRepository, imageTag, err := buildAndPushImageToTTL(ctx, source) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("SDK image pushed to %s/%s:%s\n", imageRegistry, imageRepository, imageTag) | ||
|
||
chart, err := buildAndPushChartToTTL(ctx, source, imageRegistry, imageRepository, imageTag) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Printf("SDK chart pushed to %s\n", chart) | ||
|
||
wrappedChart, err := createWrappedTestChart(ctx, source, chart) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
now := time.Now().Format("20060102150405") | ||
chartRef := fmt.Sprintf("oci://ttl.sh/automated-%s/wrapped-chart", now) | ||
chartFile := "/chart/test-chart-0.1.0.tgz" | ||
|
||
_ = dag.Container().From("alpine/helm:latest"). | ||
WithFile("/chart/test-chart-0.1.0.tgz", wrappedChart). | ||
WithExec([]string{"helm", "push", chartFile, chartRef}) | ||
fmt.Printf("\n\nWrapped chart pushed to %s:0.1.0\n\n", chartRef) | ||
|
||
return nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the files this used to use were deleted with the move to dagger