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

features - dotnet pe tester updates #178

Merged
merged 6 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions AppService-FrontDoor-PrivateEndpoints/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHealthChecks();

var app = builder.Build();

app.UseSwagger();
app.UseSwaggerUI();
app.MapHealthChecks("/health");

app.UseHttpsRedirection();

const string connStringMessage = "Connection string not found.";

app.MapGet("/testappconfig", async () =>
{
var endpoint = builder.Configuration["APP_CONFIG_ENDPOINT"] ?? "";
var key = builder.Configuration["CONFIG_NAME"] ?? "";
var key = builder.Configuration["APP_CONFIG_ENDPOINT_KEY"] ?? "";

var value = Guid.NewGuid().ToString();

Expand All @@ -45,7 +49,7 @@
var mySetting = configuration.GetValue<string>("POSTGRES_CONNECTIONSTRING");

if (string.IsNullOrEmpty(mySetting))
throw new ArgumentException("Connection string not found.");
throw new ArgumentException(connStringMessage);

await using var conn = new NpgsqlConnection(mySetting);
await conn.OpenAsync();
Expand All @@ -71,10 +75,10 @@
var mySetting = configuration.GetValue<string>("SQL_CONNECTIONSTRING");

if (string.IsNullOrEmpty(mySetting))
throw new ArgumentException("Connection string not found.");
throw new ArgumentException(connStringMessage);

using var con = new SqlConnection(mySetting);
con.Open();
await con.OpenAsync();

var version = await con.ExecuteScalarAsync<string>("SELECT @@VERSION");

Expand All @@ -95,9 +99,9 @@
var mySetting = configuration.GetValue<string>("CACHE_CONNECTIONSTRING");

if (string.IsNullOrEmpty(mySetting))
throw new ArgumentException("Connection string not found.");
throw new ArgumentException(connStringMessage);

var redis = ConnectionMultiplexer.Connect(mySetting);
var redis = await ConnectionMultiplexer.ConnectAsync(mySetting);

var cache = redis.GetDatabase();

Expand All @@ -122,7 +126,7 @@
var mySetting = configuration.GetValue<string>("STORAGE_CONNECTIONSTRING");

if (string.IsNullOrEmpty(mySetting))
throw new ArgumentException("Connection string not found.");
throw new ArgumentException(connStringMessage);

var containerName = "test-container";

Expand Down
2 changes: 1 addition & 1 deletion AppService-FrontDoor-PrivateEndpoints/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"AllowedHosts": "*",
"APP_CONFIG_ENDPOINT": "",
"CONFIG_NAME": "",
"APP_CONFIG_ENDPOINT_KEY": "",
"POSTGRES_CONNECTIONSTRING": "",
"SQL_CONNECTIONSTRING": "",
"CACHE_CONNECTIONSTRING": "",
Expand Down
62 changes: 62 additions & 0 deletions AppService-FrontDoor-PrivateEndpoints/k8s/dotnet-pe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: dotnet-pe-tester
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: dotnet-pe-tester
template:
metadata:
labels:
app: dotnet-pe-tester
annotations:
prometheus.io/scrape: 'true'
prometheus.io/path: '/metrics'
prometheus.io/port: '8080'
spec:
automountServiceAccountToken: false
containers:
- name: dotnet-pe-tester
image: ghcr.io/goncalvesj/dotnet-pe-tester:latest
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
env:
- name: APP_CONFIG_ENDPOINT
value: ""
- name: APP_CONFIG_ENDPOINT_KEY
value: ""
- name: POSTGRES_CONNECTIONSTRING
value: ""
- name: SQL_CONNECTIONSTRING
value: ""
- name: CACHE_CONNECTIONSTRING
value: ""
- name: STORAGE_CONNECTIONSTRING
value: ""
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 8080
---
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

Check notice

Code scanning / checkov

The default namespace should not be used Note

The default namespace should not be used
Fixed Show fixed Hide fixed

Check notice

Code scanning / checkov

Image should use digest Note

Image should use digest

Check notice

Code scanning / checkov

Image Tag should be fixed - not latest or blank Note

Image Tag should be fixed - not latest or blank

Check notice

Code scanning / checkov

Liveness Probe Should be Configured Note

Liveness Probe Should be Configured

Check notice

Code scanning / checkov

Minimize the admission of containers with capabilities assigned Note

Minimize the admission of containers with capabilities assigned

Check notice

Code scanning / checkov

Apply security context to your pods and containers Note

Apply security context to your pods and containers

Check notice

Code scanning / checkov

Use read-only filesystem for containers where possible Note

Use read-only filesystem for containers where possible
Fixed Show fixed Hide fixed

Check notice

Code scanning / checkov

Containers should run as a high UID to avoid host conflict Note

Containers should run as a high UID to avoid host conflict

Check notice

Code scanning / checkov

Ensure that the seccomp profile is set to docker/default or runtime/default Note

Ensure that the seccomp profile is set to docker/default or runtime/default
Fixed Show fixed Hide fixed
apiVersion: v1
kind: Service
metadata:
name: dotnet-pe-tester
namespace: default
spec:
selector:
app: dotnet-pe-tester
type: ClusterIP
ports:
- port: 8080
targetPort: 8080
Comment on lines +61 to +72

Check notice

Code scanning / checkov

The default namespace should not be used Note

The default namespace should not be used
Loading