Posts

Showing posts from 2024

wasmcloud - getting started

First ensure you have installed the right tools. The easier way to do this is using ubuntu 24.04 that has the right tooling versions.  Install wash curl -s https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh | sudo bash apt-get update apt install wash Check the version you have installed. wash --version Start to install the core components install  sudo apt install build- essential install rustc  install golang manually as wasmcloud requires golang version 1.23. export GO_VERSION="1.23.4" export GO_ARCH="amd64" curl -O -L "https://golang.org/dl/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" tar -xf "go${GO_VERSION}.linux-${GO_ARCH}.tar.gz" sudo chown -R root:root ./go mv -v go /usr/local export PATH=$PATH:/usr/local/go/bin Install tinygo export TINYGO_VERSION="0.34.0" export TINYGO_ARCH="amd64" curl -O -L "https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo_${TINYGO_VERSION}_${...

wsl - installing ubuntu 24:04

You can follow the guide here to install ubuntu 24.04 for wsl windows.  Run the following command wsl --install -d Ubuntu-24.04  This installation tends to pave the way for more recent version the tooling required for your development needs. 

keycloak 24 - debugging with visual studio code

Image
First you need to install jdk 17 (if you're working with keycloak 24) or jdk 21  (for anything higher) and ensure you have maven installed. java -version git --version Next clone keycloak repository using the following command:  git clone https://github.com/keycloak/ keycloak.git cd keycloak Build only the server.  ./mvnw -pl quarkus/deployment,quarkus/ dist -am -DskipTests clean install Once it is all build successfully. We will configure vscode. Fire up vscode if you have not already done so and ensure you are in the keycloak repository. Ensure you have install java debugging extension. Then create launch.json that looks like this {     // Use IntelliSense to learn about possible attributes.     // Hover to view descriptions of existing attributes.     // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387     "version" : "0.2.0" ,     "configurations" : [         {   ...

yarn installing to the latest version

To install yarn to the lates version, all we need to do is run the following command: yarn set version stable

yarn equivalent for npx

  Let's say we're trying to execute  npx codemod react/19/remove-context-provider --target <path> The equivalent yarn command for this would be  yarn dlx codemod react/19/remove-context-provider --target <path>

upgrading to react 19

Image
To upgrade to react 19, all you need to do is the use the following command, if you're using yarn and typescript:-  yarn add -- exact @ types /react@^19.0.0 @types/ react - dom @^ 19.0 . 0 This would create the following changesets.  New JSX transform has been added which improve bundle size.   

Azure vnet allocating and planning subnets

Image
 When setting up Azure VNET it is important to plan your address spaces especially when it is intended for use with AKS - as these ips cannot overlap. When creating VNET, you are required to configure your address spaces before you can use it.  Altho you can come back and change it but then might take some additional effort. This is how you can change your VNET address spaces. After you created these, then you will start to create subnets which in terms harness these configurations. So it important to have some planning in place.

AKS configuring pod-cidr with portal (not possible)

Image
We can configure pod-cidr on the portal using the following UI is not possible. The configuration below helps to configure service-cidr. What is service cidr? Service cidr is the ip address range used for provisioning of nodes. If you create a new node, then an ip will be assigned to this node. This ip gets it range from service cidr.  When you create cluster1, the pod cidr is always in the range 10.244.x.x. If you crate another cluster say cluster 2 will also be 10.244.x.x. This won't work if you trying to setup a multimesh like cilium that requires pod address to be unique.  You can use the following to configure your pod cidr. az network vnet create \     --resource-group "${ AZURE_RESOURCE_GROUP }" \     --name "${ NAME }-cluster-net" \     --address-prefixes 192.168.10.0/24 \     --subnet-name "${ NAME }-node-subnet" \     --subnet-prefix 192.168.10.0/24 # Store the ID of the created subnet export NODE_SUBNET...

windows wsl resetting password for root or user

From the powershell of the application, run the following command  wsl --user root and then to reset your password simple run  passwd

kind create cluster - the node with the same name already exist

Image
If you're having this error, the way to resolve it is to delete the container. In my case, i am running docker so I had to remove the running container.    

kubectl - setting the API server endpoint

We can use the following to configure server endpoint ip kubectl config set-cluster kind-cluster1 --server=https://172.19.0.2:6443

c# and react implementation of kata08 code challenge

My sample implementation of the kata code challenge can be found here:- https://github.com/mitzenjeremywoo/mitzenjeremywoo-kata08-test--challenge

terraform azurerm - registering azure provider

To register a specific provider, we typically would do the following.   az provider register --namespace Microsoft.PolicyInsights You can do the same thing by running the following configuring the following in terraform:  resource "azurerm_resource_provider_registration" "policyregistration" {   name = "Microsoft.PolicyInsights" }

azure devops c# dotnet core sdk - creating build definition / pipeline for your repository.

Creating azure devops build definition can be challenging due to the large options that is available. Below is the most basic code sample that you can use the successfully create a build definition (essentially a pipeline) for your repository.  Please note: You might get into other issues like invalid service connection, etc. Really depends on what you specify in the build definitions.  Suggest that you make incremental changes. Here is the code base.  var _azureGitClient = connection.GetClient < BuildHttpClient > (); var buildDefinition = new BuildDefinition {     Name = "My New Build Definition" ,     Project = new TeamProjectReference { Name = projectName , Id = repo.ProjectReference.Id } ,       Repository = new BuildRepository     {         Type = RepositoryTypes.TfsGit ,         Name = "name-of-your-repository" ,         Url = new Uri($ "https...

azcopy error: get cached token failed to ensure token fresh

Looking into an azcopy issue complaining about this error.  " failed to perform copy command due to error: get cached token failed to ensure token fresh, please log in with azcopy's login command again, Manually created ServicePrincipalToken does not contain secret material to retrieve a new access token" . I am sure my service principal is working fine and has the proper secrets and expiry configured.  And was able to resolve this by using azcopy binary version 10.27.1 (the latest at this time).  No luck with version 10.25.0 

sqlpackage vs sqlcmd

sqlpackage is a tool that allows us to deploy sqlproj/dacpac/bacpac files across different platform such as windows, linux. It uses a slightly different sqlproj format - removing some of the dependencies sqlproj has on msbuild.  Unfortunately it cannot be used for ispac / ssis packages.  I was abit confused when the docs mentioned  SqlAzureDacpacDeployment  - giving me the impression that sqlpackages is readily available as an azure devops task.  Upon some googling - this tasks uses sqlcmd.  The differences between sqlpackage and sqlcmd are highlighted below:-  Key Differences Feature SqlPackage sqlcmd Primary Purpose Database schema and data management (DACPAC/BACPAC). SQL script execution and database interaction. Typical Use Cases - Deploying database schemas. - Extracting or exporting schemas and data. - Publishing database updates. - Running ad hoc T-SQL commands. - Automating scripts for database tasks. - Querying or modifying data directly. Inpu...

quick code snippet to setup automoq

 This is a quick start example of setup mock for Automoq.  var mocker = new AutoMocker (); var creditCardValidator = mocker . CreateInstance < CreditCardValidator >(); mocker . GetMock < ICreditCardValidator >(). Setup ( x => x . Validate ( "fakecardnunber" , new DateTime ( 2024 , 12 , 12 ))). Returns ( new CreditCardValidationResult ( "" , true )); var result = creditCardValidator . Validate ( "fakecardnunber" , new DateTime ( 2024 , 12 , 12 )); Assert . IsTrue ( result . Valid );                    

istio envoyfilter lua to do some logging

Sometimes for doing troubleshooting, we need to create an envoyfilter to logs certain responses or headers related data. To do so we can use the following example:-  apiVersion : networking.istio.io/v1alpha3 kind : EnvoyFilter metadata :   name : log-headers   namespace : default spec :   workloadSelector :     labels :       app : httpbin   configPatches :   - applyTo : HTTP_FILTER     match :       context : SIDECAR_INBOUND     patch :       operation : INSERT_BEFORE       value :         name : envoy.filters.http.lua         typed_config :           '@type' : type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua           inlineCode : |             function envoy_on_request(request_handle)               req...

react app - creating a container and renders outputs from a rest API call

 This is a simple component that serves as a container to load data and renders its output using another component called ProductItem. Here is an example of the container code. It uses react useEffect to call an API endpoint.  import { ProductItem } from "./ProductItem" ; import { useEffect , useState } from "react" ; import { Item } from "./Item" ; import { ProductFetchEndpoint } from "../AppConstant" ; import { CalculateTotal } from "./CalculateTotal" ; const ProductContainer = () => {   const [ items , setStoreItems ] = useState < Item []>([]);   const [ loading , setLoading ] = useState < boolean >( true );   const [ error , setError ] = useState < string | null >( null );   useEffect (() => {     const fetchProducts = async () => {       try {         setLoading ( true );         setError ( null );         co...