Posts

AKS - couldn't get current server API group list dail tcp lookup 443 timeout

 Well this sounds like you have an issue connecting (obviously) - Goto Azure portal -> Find your AKS cluster and click on the connect button. Then you need to provide  az aks get-credentials --resource-group my-resource-group --name myaks-cluster Well sometimes we do forgets to re-authenticate to a new cluster. You can use the following to test connectivity to your cluster - assuming you have access to the kubernetes API   az aks command invoke \   --resource-group my-resource-group \   --name myaks-cluster \   --command "kubectl get pods -n kube-system"

notes about k8s pdb

Image
  Let's say we have the following pdb and deployment httpbin.yaml # Copyright Istio Authors # #   Licensed under the Apache License, Version 2.0 (the "License"); #   you may not use this file except in compliance with the License. #   You may obtain a copy of the License at # #       http://www.apache.org/licenses/LICENSE-2.0 # #   Unless required by applicable law or agreed to in writing, software #   distributed under the License is distributed on an "AS IS" BASIS, #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #   See the License for the specific language governing permissions and #   limitations under the License. ################################################################################################## # httpbin service ################################################################################################## apiVersion : v1 kind : ServiceAccount metadata :   name : httpbi...

kubernetes 1.26 - spec.unhealthyPodEvictionPolicy support for PDB

  Some enhancement to PDB, we can add unhealthyPodEvictionPolicy to pdb that supports 2 options 1. IfHealtyBudget - eviction is possible if min desiredHealthy is met.  2. AlwaysAllow - we can always evict the pods  Sample yaml o test for k1.26 apiVersion : policy/v1 kind : PodDisruptionBudget metadata :   name : nginx-pdb spec :   selector :     matchLabels :       app : nginx   maxUnavailable : 1   unhealthyPodEvictionPolicy : AlwaysAllow

az --debug

Right noticed i ca run az cli command with --debug to print out some debugging info. Nice! :)

bicep create deployment with template id - awkwardness

  For some reason when I tried to deploy using az deployment group command, the template id has to be parameterized $id.    az deployment group create \   -- resource - group dbrg \   -- template - spec $ id \   -- parameters storageName =" mytestapp1212 " location =" australiaeast " I tried using different approach for example, double quote   az deployment group create -- resource - group dbrg -- template - spec "/ subscriptions / FAKESUBSCRIPTION / resourceGroups / mydeployment - dev - rg / providers / Microsoft . Resources / templateSpecs / storageSpec / versions / 1 . 0 " -- parameters storageName =" mydatastore1122 " location =" australiaeast "  No quotes    az deployment group create -- resource - group dbrg -- template - spec / subscriptions / FAKESUBSCRIPTION / resourceGroups / mydeployment - dev - rg / providers / Microsoft . Resources / templateSpecs / storageSpec / versions / 1 . 0 -- parameters stor...

node-fetch - is built into nodejs

  Instead of importing node-fetch, spending hours trying to make it work with typescript, all you need to do is  /// nf.js fetch ( 'https://www.google.com' )     . then (( response ) => response . text ())     . then (( body ) => {         console . log ( body );     }); Then execute it using command " node -- experimental - fetch nf.js

azure managed identity with federated identities

 What does it means with a limit of 20 federated identities per managed identities?  This means one managed identities is limited by a combined sum of the feature below:  1. github integrations  2. kubernetes namespace and service account  3. Others  So you can have 10 github integration, 5 federation to kubernetes namespace and other 5 other integration but not more. Or you can have federation to 20 AKS namespace. Normally I would go for 1 managed identities for a namespace so i don't have to deal with the limitation of 20 namespaces for a managed identities.  Does it means I can have a max limit of 20 managed identities per kubernetes cluster or Azure AD?  Not at all.  Does it means my managed identities RBAC access say storage contributor can be granted for 20 Azure resources? Not at all . 

upgrading typescript but getting EEXIST: file already exists

  As stated in stackoverflow, this can be fix via  npm install -g typescript@latest --force

nodejs - environment variable used

 This link provide a documentation of what environment variables and configure allow in nodejs. https://nodejs.org/api/cli.html#cli_environment_variables

nodejs - setting debug mode for a module via environment variable

 If you need to debug, say https request, then you can set this in your environment variable  NODE_DEBUG =https Then run any nodejs code that makes a request to this module. You can see debugging info gets spitted out. 

getting elapse time using console.time/endtime

Image
  By running console.time("your-time-label") and then console.endTime("your-time-label"), you automatically get elapse time of your process. import request from 'request' ; import process from 'node:process' ; function exec ( i : number ) : Promise < void >  {   return new Promise (( resolve , reject ) => {       request . get ( 'http://www.google.com' , ( err : any , resp : any ) => {       if ( err ) {         reject ( 'error' );         return console . error ( err );       }       console . log ( "Total bytes received: " , resp . body . length , process . pid , i );         resolve ( resp . body . length );       });   }) } console . time ( "test" ); const promises = []; for ( let i = 0 ; i < 5 ; ++ i ) {     promises . push ( exec ( i )); } Promise . all ( promises ) . then (( res...

typescript - Cannot find module 'worker_threads'

 Just run npm install  @types/node

nextjs - dynamic route with [...mydynamicroute].tsx

Nextjs dynamic route are different from APP and PAGES.  For example the following are setup for app router  App Route definition  /app/product/[slug]/page.tsx       Request for:  /product/a -> OK  /product/b -> OK  /product/a/b -> Not Ok - To support this your need to define route with something like this  /app/product/[...slug]/pages.tsx The test contents for file are shown here export default function Page ({ params } : { params : { slug : string } }) {     return < div > My Post: { params . slug } </ div >   } Page router  Notice page router uses "useRouter" and catch all segment uses [..page].ts (file - not folder).  So we place this under /page/shop/[slug].tsx - Not /pages/api/shop -> that's something else and the intention is for API.  Our dynamic route definition is like this  /page/shop/[slug].tsx   Request for  pages/shop/a --> Ok pages/sh...

Nextjs :- API resolved without sending a response

The endpoint that you're hitting are probably not returning anything to the browser. This normally happens when you trying to create dynamic routes for example.  You can try to use the following to force it to return "ok". export default async function ( req , res ) {   try {     const response = "ok" ;     res . statusCode = 200 ;     res . setHeader ( 'Content-Type' , 'application/json' );     res . setHeader ( 'Cache-Control' , 'max-age=180000' );     res . end ( JSON . stringify ( response ));   }   catch ( error ) {     res . json ( error );     res . status ( 405 ). end ();   } }

nextjs - auth0 sample configuration

Clone the auth0 sample using the following command npx create-next-app --example auth0 auth0-app  Next, cd auth0-app. Ensure you created a file call .env.local  Then you need to configure the followings  AUTH0_ISSUER_BASE_URL = "https://yourappdomain.auth0.com" AUTH0_CLIENT_ID = your-regular-app-client-id AUTH0_CLIENT_SECRET = your-regular-app-client-secret AUTH0_BASE_URL = "http://localhost:3000" AUTH0_SECRET = ede7edc615ee5a58c0791794f704981c In Auth0, please ensure you created Regular Web App.  I also tried using SPA - it works. Open up this page : https://manage.auth0.com/ and then select your application. Ensure " Allowed callback url " is configured to http://localhost:3000/api/auth/callback Also ensure "Allowed logout url" is configured to http://localhost:3000 Save your changes and your app should be good to go.

keycloak operator installing crds

Not entirely sure why but this docs, only install half of the crds required as shown here https://www.keycloak.org/operator/installation. The full crd can be found here , so you can work and deploy these instead.

getting current established network connection

  The following command can help:- ss -tuln | grep -c 'ESTAB

Mongodb changing user password

Image
 Login to mongodb Atlas, then on your left select "Database Access". Then select the user that you would like to edit or change the password. 

typescript 5.1 no longer issue error if your function returned type is not void or any

Typescript v 4.9.5 would throws an error if you have your code written like this  function f4 () : undefined {     // no returns } In version 5.1 (not 5.0) writing code above is fine. That's easy to understand. The code below would work for typescript 5.1 but not anything lower.      // this works for 5.1 but not for anything lower     function takesFunction ( f : () => undefined ) : undefined     {     }     takesFunction (() => {         // no returns     });         takesFunction (() : undefined => {         // no returns     });         takesFunction (() => {         return ;     });     takesFunction (() => {         return undefined ;     });     takesFunction (() : undefined => {      ...

bicep referencing existing resources

  For resource group it is scope to a subscription. As for the storage account, it scopes is to an existing resource group. targetScope = 'subscription' resource newRG 'Microsoft.Resources/resourceGroups@2021-01-01' existing = {   name : 'bicep-test-rg' } resource stg 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {   name : 'mydevdatastore'   scope : resourceGroup ( newRG . name ) } output blobEndpoint string = stg . properties . primaryEndpoints . blob