restingphantom
restingphantom
Explore posts from servers
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
Yeah, I don't need to put those in there, but I do however need my git secrets :/
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
Changing the path is no issue, just getting them from all separate files into one singular appsettings file (or env if that would work as well) is what I'm struggling with
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
I would preferibly would have all of them in my appsettings.json as a json instead of each having their own separate file
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
I have already looked a bit at configmaps, but I dont know how they work exactly and how I can implement it while also getting my secrets from my keyvault
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
im new to kubernetes and azure and I need some direction on what I can use to map my secrets to my C# application
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
# This is a SecretProviderClass example using user-assigned identity to access your key vault
# Service Connector sets up the Azure resource connection, users only need create the SecretProviderClass and workload resources
# For the variables to fill in, you may get their values from Service Connector Azure Portal


apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: brewing-secretsprovider
namespace: brewingstand
spec:
provider: azure
parameters:
usePodIdentity: "false"
useVMManagedIdentity: "true" # Set to true for using managed identity
userAssignedIdentityID: MyId # Set the clientID of the user-assigned managed identity to use
keyvaultName: brewingKeys # Set to the name of your key vault
objects: | # Secrets in Azure Key Vault
array:
- |
objectName: appsettings-allowedorigins
objectType: secret
- |
objectName: connectionstrings-azureblobstorage
objectType: secret
- |
objectName: connectionstrings-postgresql-db
objectType: secret
- |
objectName: gitsecrets-client
objectType: secret
- |
objectName: gitsecrets-secret
objectType: secret
- |
objectName: jwtsettings-secretkey
objectType: secret
- |
objectName: logging-loglevel-default
objectType: secret
- |
objectName: logging-loglevel-microsoftaspnetcore
objectType: secret
tenantId: myId # The tenant ID of the key vault
# This is a SecretProviderClass example using user-assigned identity to access your key vault
# Service Connector sets up the Azure resource connection, users only need create the SecretProviderClass and workload resources
# For the variables to fill in, you may get their values from Service Connector Azure Portal


apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: brewing-secretsprovider
namespace: brewingstand
spec:
provider: azure
parameters:
usePodIdentity: "false"
useVMManagedIdentity: "true" # Set to true for using managed identity
userAssignedIdentityID: MyId # Set the clientID of the user-assigned managed identity to use
keyvaultName: brewingKeys # Set to the name of your key vault
objects: | # Secrets in Azure Key Vault
array:
- |
objectName: appsettings-allowedorigins
objectType: secret
- |
objectName: connectionstrings-azureblobstorage
objectType: secret
- |
objectName: connectionstrings-postgresql-db
objectType: secret
- |
objectName: gitsecrets-client
objectType: secret
- |
objectName: gitsecrets-secret
objectType: secret
- |
objectName: jwtsettings-secretkey
objectType: secret
- |
objectName: logging-loglevel-default
objectType: secret
- |
objectName: logging-loglevel-microsoftaspnetcore
objectType: secret
tenantId: myId # The tenant ID of the key vault
11 replies
CC#
Created by restingphantom on 1/14/2025 in #help
✅ Kubernetes Secret-provider to env variables
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-login-deployment
namespace: brewingstand
spec:
replicas: 1
selector:
matchLabels:
app: service-login
template:
metadata:
labels:
app: service-login
spec:
containers:
- name: service-login
image: ghcr.io/brewing-stand/service-login:master
ports:
- containerPort: 8080
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
volumeMounts:
- name: secrets-store
mountPath: "/mnt/secrets-store"
readOnly: true
volumes:
- name: secrets-store
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "brewing-secretsprovider"
apiVersion: apps/v1
kind: Deployment
metadata:
name: service-login-deployment
namespace: brewingstand
spec:
replicas: 1
selector:
matchLabels:
app: service-login
template:
metadata:
labels:
app: service-login
spec:
containers:
- name: service-login
image: ghcr.io/brewing-stand/service-login:master
ports:
- containerPort: 8080
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "1Gi"
cpu: "500m"
volumeMounts:
- name: secrets-store
mountPath: "/mnt/secrets-store"
readOnly: true
volumes:
- name: secrets-store
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: "brewing-secretsprovider"
11 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
thanks for the help though
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
it auto implements from envoirement.dev instead of just envoirenment
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
No description
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
I found it already
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
I didnt even notice that
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
thats where my api is when running loccally!?
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
at least I believe them to be, because i unfortionately dont have access to them
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
The front-end is hosted somewhere else, the env variables during production are https://HOST.net and http://HOST.net
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
the CORS error dont occur in my dev env. only in production
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
C#
global using HTXL_Back_end.Models;
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Filters;

var corsPolicy = "CorsPolicy";

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

// Authentication
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey =
new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(builder.Configuration.GetSection("AppSettings:Token").Value!)),
ValidateIssuer = false,
ValidateAudience = false
};
});

// CORS
builder.Services.AddCors(options =>
options.AddPolicy(corsPolicy, policy => policy
.WithOrigins(builder.Configuration.GetSection("AppSettings:AllowedOrigins").Get<string[]>()!)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()));

builder.Services.AddDbContext<HTXLPortfolioContext>();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseCors(corsPolicy);

app.UseHttpsRedirection();

app.UseAuthentication();

app.UseAuthorization();

app.MapControllers();

app.Run();
C#
global using HTXL_Back_end.Models;
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Filters;

var corsPolicy = "CorsPolicy";

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

// Authentication
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey =
new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(builder.Configuration.GetSection("AppSettings:Token").Value!)),
ValidateIssuer = false,
ValidateAudience = false
};
});

// CORS
builder.Services.AddCors(options =>
options.AddPolicy(corsPolicy, policy => policy
.WithOrigins(builder.Configuration.GetSection("AppSettings:AllowedOrigins").Get<string[]>()!)
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()));

builder.Services.AddDbContext<HTXLPortfolioContext>();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseCors(corsPolicy);

app.UseHttpsRedirection();

app.UseAuthentication();

app.UseAuthorization();

app.MapControllers();

app.Run();
32 replies
CC#
Created by restingphantom on 5/28/2024 in #help
✅ Cors Errors on new API controller
my program.cs looks as followed
32 replies
CC#
Created by restingphantom on 5/14/2024 in #help
✅ .NET SDK does not support targeted version
thanks for the help anyways, hopefully nothing breaks again
18 replies
CC#
Created by restingphantom on 5/14/2024 in #help
✅ .NET SDK does not support targeted version
I got things to work again, I had to update al packages and sql was doing some funny things but it seams to be fine again
18 replies