Posts

Showing posts from October, 2024

running into dotnet sdk 7 issue when running dotnet run -- schema export --output schema.graphql

Image
  When running "dotnet run -- schema export --output schema.graphql", you will hit this error if you don't have dotnet 7.11x installed. So you need to download 7.11x - it can be higher but cannot be 7.3x or 7.4x Once you install it, this error should go away. 

hotchoc - error CS0121: The call is ambiguous between the following methods or properties: 'SchemaRequestExecutorBuilderExtensions.AddTypes(IRequestExecutorBuilder

Image
When you're trying to use AddTypes() to build up your service and if you bump into this error message.   error CS0121: The call is ambiguous between the following methods or properties: 'SchemaRequestExecutorBuilderExtensions.AddTypes(IRequestExecutorBuilder, params Type[])' and 'SchemaRequestExecutorBuilderExtensions.AddTypes(IRequestExecutorBuilder, params INamedType[])' 1>Done building project "Accounts.csproj" -- FAILED. This is discussed here https://github.com/ChilliCream/graphql-platform/discussions/5845.    And ensure your module is configured Finally ensure that you have the proper attributed in place - as the code will be generated on the fly. For example, this is what my query looks like.  And then try to compile and see if that works for you. It did work for me. 

hotchoc fusion commands - exporting schema, packing and composing your supergraph

Image
 To get started please run  dotnet new tool-manifest Then install hotchoc fusion command  dotnet tool install HotChocolate.Fusion. CommandLine Then go to your subgraph project such as account or product or review. Ensure that you have "RunWithGraphQLCommands" configured as shown below:- using System . Numerics ; var builder = WebApplication . CreateBuilder ( args ); builder . Services     . AddSingleton < UserRepository >(); builder . Services     . AddGraphQLServer ()     . AddTypes ()     . AddGlobalObjectIdentification ()     . RegisterService < UserRepository >(); var app = builder . Build (); app . MapGraphQL (); app . RunWithGraphQLCommands ( args ); Then run the following command in your subgraph project to generate the graphql schema. dotnet run -- schema export --output schema.graphql Next run  dotnet fusion subgraph pack This will create a package with extension ccspkg, that contains sch...

kubernetes liveness readiness and startup probes

Kubernetes tends to mask the actual health check endpoint into something such as /health/ready or /health/live.  I was trying to configure livenessProbe and turns on it also requires readinessProbe and startupProbes. Let's use keycloak as an example. It exposes different healthcheck endpoint on port 8080.  Keycloak exposes 4 health endpoints: /health/live /health/ready /health/started /health So in my kubernetes health check configuration i would have something below: readinessProbe :   httpGet :     path : /health/live     port : 8080   failureThreshold : 1   periodSeconds : 10 livenessProbe :   httpGet :     path : /health/ready     port : 8080   failureThreshold : 1   periodSeconds : 10 startupProbe :   httpGet :     path : /health/started     port : 8080   failureThreshold : 30   periodSeconds : 10 FAQ  Do you need all to be configured?  Very likely yes. It is...

snyk throwing EACCES with error code 13 when running snyk-linux code test

  My pipeline was throwing EACCESS err 13 trying to spawn gradle when I ran snyk code test using SnykSecurityScan@1.  I can see that snyk linux was successfully downloaded and installed. To resolve this, I set the folder permission to allow it to execute gradle.  chmod -R +x $(Build.SourceDirectory)  After that my snyk task was able to run successfully.

who is calling my kubernetes health check endpoint - /health/ready

The other day, I had massive amount of traffic calling my pods health check endpoint and trying to identify where the call is coming from.  It turns out that the agent is kube-proxy/<your-kubelet-version> and yes it is no other than kubelet itself. 

using openssl to create a self sign certificate

  The following command generate a self signed certificate for 365 days. openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -nodes

install nginx service mesh

Image
  Installing NGINX service mesh First of all, you need to install monitoring components for nginx service mesh.  Clone from this repo https://github.com/mitzenjeremywoo/nginx-service-mesh-setup.git and then run the following command. kubectl apply -f prometheus.yaml -f grafana.yaml -f otel-collector.yaml -f jaeger.yaml Next use helm to install the service mesh helm repo add nginx-stable https://helm.nginx.com/stable helm repo update helm install nsm nginx-stable/nginx-service-mesh --namespace nginx-mesh --create-namespace --wait --set prometheusAddress=prometheus.nsm-monitoring.svc:9090 --set telemetry.exporters.otlp.host=otel-collector.nsm-monitoring.svc --set telemetry.exporters.otlp.port=4317 --set telemetry.samplerRatio=1 Deploying bookinfo sample app.  We need to label the namespace first - just like how we do it in Istio. kubectl label namespaces default injector.nsm.nginx.com/auto-inject=enabled and then run this command to deploy book info. kubectl apply -f bookin...

installing and setting up nginx-ingress controller tutorial

Image
 This tutorial covers only nginx ingress controller and not the service mesh.  Install NGINX ingress controller using helm Add nginx ingress controller helm repository  helm repo add nginx https://kubernetes.github.io/ingress-nginx Then update it using the following command helm repo update  Install nginx ingress controller by running the command here helm upgrade --install ingress-nginx ingress-nginx --repo https://kubernetes.github.io/ingress-nginx --namespace ingress-nginx --create-namespace To see what are the values that is available when running helm upgrade, you can use the following command: helm show values ingress-nginx --repo https://kubernetes.github.io/ingress-nginx To test your ingress installation so far.  kubectl get service ingress-nginx-controller --namespace=ingress-nginx The service will have an External-IP, in this case it is localhost. Deploy the book info application  # Copyright 2017 Istio Authors # #   Licensed under the Apache...

provisioning resources with cdk aws go

Image
  Install aws cdk is the first step we have to do.  npm install -g aws-cdk Next create the directory mkdir hello-cdk && cd hello-cdk Initialize your target development language cdk init app --language go That will generate some codes for you and run command below to generate download the required packages.  go get Use the following code and provide your account. package main import (     "github.com/aws/aws-cdk-go/awscdk/v2"     "github.com/aws/aws-cdk-go/awscdk/v2/awslambda"     "github.com/aws/constructs-go/constructs/v10"     "github.com/aws/jsii-runtime-go" ) func main () {     defer jsii . Close ()     app := awscdk . NewApp ( nil )     NewHelloCdkStack ( app , "HelloCdkStack" , & HelloCdkStackProps {         awscdk . StackProps {             Env : env (),         },     })     app . Synth ( ...

cdktf example using providers kreuzwerker/docker

Image
First ensure you have install the cli cdktf, node 20.x and have a docker running.  Then run the following command to create a folder. mkdir learn-cdktf-docker cd learn-cdktf-docker Generate the code using  cdktf init --template=go --providers=kreuzwerker/docker --local You may need to do "go get github.com/cdktf/cdktf-provider-docker-go/docker/v11" - if the scaffolding give you some error.  The terraform website provides some older code which work with older version of provider. I have updated with a newer provider Noticed that I am using github.com/cdktf/cdktf-provider-docker-go/docker/v11/container instead of  "github.com/hashicorp/cdktf-provider-docker-go/docker/v3/container" You can go and check what is the correct version to use by going to this endpoint.  https://github.com/cdktf/cdktf-provider-docker-go/blob/main/docker/go.mod#L1 Sometimes we get tripped because we think the readme file would provide all we needed.  package main import ( ...

cdktf deploy - Raw mode is not supported on the current process.stdin

When i was trying to run cdktf deploy, this error keeps coming up. My bash terminal wasn't working too well on Windows - so to avoid getting prompts, i ran it with the auto approve switch. cdktf deploy --auto-approve   Then i was able to get around this. 

cdktf install - getting 'EINVAL' -4048 - unable to install

Bump into this error while trying to install cdktf binaries  scripts/check-prebuild.js || prebuild-install || node scripts/install.js 2353 info run @cdktf/node-pty-prebuilt-multiarch@0.10.1-pre.11 install { code: 1, signal: null } 2354 warn cleanup Failed to remove some directories [ 2354 warn cleanup   [ 2354 warn cleanup     [Error: EPERM: operation not permitted, rmdir 'AppData\Roaming\npm\node_modules\cdktf-cli\node_modules\@sentry-internal'] { 2354 warn cleanup       errno: -4048, 2354 warn cleanup       code: 'EPERM', 2354 warn cleanup       syscall: 'rmdir', 2354 warn cleanup       path: 'AppData\\Roaming\\npm\\node_modules\\cdktf-cli\\node_modules\\@sentry-internal' 2354 warn cleanup     } 2354 warn cleanup   ], I am using node 22.x and then i had to remove and re-install node 20.x. In the new installation,  i checked the option to allow nod...

golang - creating, publishing and consuming a module

Image
 To create a module, I have the following directory/folder layout In my root go.mod - the code looks like this  module github.com/mitzenjeremywoo/myfirstgolibrary go 1.20 And the math.go code package math func Add ( x int , y int ) int {     return x + y } func Minus ( x int , y int ) int {     return x - y } Try to compile and once everything looks good, we will publish it. To publish it  git tag v1.0.3 git push origin v1.0.3 The consuming app  You can use the following code below to consume the module above. You might need to run  go mod init myapp go get github.com/mitzenjeremywoo/myfirstgolibrary You can use the following code to call the Math.Add and Math.Minus function. package main import (     "fmt"     m "github.com/mitzenjeremywoo/myfirstgolibrary/math" ) func main () {     fmt . Println ( "test test " )     fmt . Println ( m . Add ( 10 , 20 ))     fmt . Println ...

AWS EKS connect and setup kubectl

To setup your kubectl to talk to your eks cluster, ensure you hav setup your aws cli and then run the following command: aws eks update-kubeconfig --region ap-southeast-2 --name my-eks-cluster-name Then deploy and interact at will.

terraform error │ > API version 2019-XX-XX was not found for Microsoft.Foo ` │ Original Error: determining which Required Resource Providers require registration: the required Resource Provider "Microsoft.TimeSeriesInsights" wasn't returned from the Azure API

Bump into this error today, │ > API version 2019-XX-XX was not found for Microsoft.Foo  │ Original Error: determining which Required Resource Providers require registration: the required Resource Provider "Microsoft.TimeSeriesInsights" wasn't returned from the Azure API To resolve this, we can either update the azurerm provider to a more recent version or    provider "azurerm" {   features {}   skip_provider_registration = true }

docker debugging to outputs results with --progress=plain

 Whenever we run the following to build an image, we sometimes bump into an issue and would like more verbosity / outputs to see what it is actually doing  docker buildx build . -t checkout:1.0.0   Instead of the command line above,  docker buildx build . -t checkout:1.0.0 --progress=plain This provide lost of verbosity and shows more details.

grpc - reconnecting the client and server

  Setting up the grpc server Create a ASP.net core gRPC core service. Provide a name for it and then click "next" and complete the service creations.  The proto file looks something like this below:- syntax = "proto3" ; option csharp_namespace = "myGrpcService" ; package greet ; // The greeting service definition. service Greeter {   // Sends a greeting   rpc SayHello ( HelloRequest ) returns ( HelloReply ); } // The request message containing the user's name. message HelloRequest {   string name = 1 ; } // The response message containing the greetings. message HelloReply {   string message = 1 ; } You should be able to run the server and note down the expose endpoint. Please get the https://localhost:port-number. Setting up the client  Create a console app and then add the following package. Install-Package Grpc.Net.Client Install-Package Google.Protobuf Install-Package Grpc.Tools Then add the proto file used in creating the se...