
Katzenjammer del 22 Luglio 2024
Podcast: Play in new window
Subscribe: RSS
Scaletta di Katzenjammer del 22 Luglio 2024
JADE – Angel Of My Dreams
Alessia Cara – Dead Man
Franz Ferdinand – Take Me Out
Grifoni – Testa tra le nuvole
Ditonellapiaga – Latitante
Willie Peyote, PUGNI, Fudasca – Bloody Mary
AC/DC – You Shook Me All Night Long
Riva – Una stella distante anni luce
Meganoidi – Zeta reticoli
Tre Allegri Ragazzi Morti – Il mondo prima
Shandon – Viola
Moravagine – Occasioni Perse
Green Day – American Idiot
Milky Chance – Stolen Dance
R.E.M. – Orange Crush
Pink Floyd – Comfortably Numb

IL MOMENTO DEL REVIVAL NOVANTA
All’indomani del concerto di Cristina D’Avena a Colleferro (luglio 2022) scrissi che “dopo anni di Dik Dik e Camaleonti (e taccio volutamente sul nome di Gigione) il pubblico target della festa di Sant’Anna (ed estensivamente della macroestate colleferrina, ndr) siamo noi. Non esistono categorie di consumi (es.: apericene lunghe con vista apericolazione, tatuaggi, automobili, pizze al pata negra) che possano smentire questo dato incontrovertibile.” Avevo ragione. Quindi, dopo l’interlocutorio main event dello scorso anno (Jerry Calà che cantava cover di chiunque), organizzatori e pubblico si sono ritrovati nel caldo abbraccio del revival anni ’90, epoca in cui sia gli uni che gli altri sono stati veramente giovani.
A mia memoria di storico e antropologo della colleferraggine non ricordo altro evento con tanta gente quanta ne ho vista in occasione dello spettacolo “Nostalgia ’90” del 15/7. La folla andava dalla bocciofila all’ingresso principale della scuola media. Gli esercizi di somministrazione limitrofi o hanno finito tutto o hanno imprecato al cielo per non essere stati aperti. Il gradimento generale per l’amministrazione è cresciuto nella stessa proporzione di quello di Donald Trump dopo il fallito attentato in Pennsylvania.
Per due ore le migliaia (non so quantificare ma erano migliaia, plurale) di accorsi si sono sollazzati con quei suoni così lontani e così familiari danzando ed urlando nei “popporopò” e suoi multipli tutta la vitalità generazionale repressa dal fatto che gli anni ’90, a ben vedere, sono durati solo 10 anni. Vanno ovviamente considerate le propaggini giovanili sfociate negli “anni zero” ed i performer non hanno mancato di includere nel repertorio dello spettacolo anche diversa roba extra. E’ stata spesso reiterata, forse troppo, quella canzone che fa “popporopo? (pausa di 2/4) popporopo?? (pausa di 1/4) popporoporoporoporoporopo!” (capito qual è?). Discutibili, considerato il vastissimo repertorio di hit da cui attingere, anche certi remix nazionalpopolari (Ricchi e Poveri, Umberto Tozzi) e l’insistenza, nella seconda parte dello spettacolo, con gli 883: una sola canzone bastava. Alla fine, e ve lo dice uno a cui questa musica è sempre stata indifferente o sul cazzo, non sono stati riprodotti brani epitomici tipo:
1- “We like to party” dei Vengaboys (“Arriva il Venga pullman e tutti quanti zompano, da New York a San Francisco una discoteca interurbana”)
2- “Let a boy cry” di Gala (struggente inno ribelle della mia prima – ed ultima – estate denz, 1997 A.D.)
3- “My heart goes boom” di French Affair (“tariraraaa mitraglia alcolizzà”)
4- “I’m so excited” di Nina Badric (remix dance del brano omonimo delle Pointer Sisters nota presso taluni come “la canzone dell’ano”, se l’ascolti capisci perchè).
C’era invece, ed è stata cantata a cazzo ora come allora, “Freed from desire” di Gala che, sia chiaro a tutti una volta per tutte, non nomina mai e in alcun modo l’isola di Stromboli (bensì dice “he’s got his strong beliefs”). Ditemi poi, in seconda analisi, se, come me, pensate che il testo parli di andropausa.
Adesso si replica il 29/7 (curiosamente sempre di lunedì, come se i sopravvissuti degli anni ’90, come negli anni ’90, non dovessero lavorare) per evento “Destinazione ’90” (non più “Nostalgia ’90”). Era già stato programmato a suo tempo? L’hanno programmato alla svelta dopo il successo dell’altro? Sarà troppo presto per un’iniziativa identica a quella di due settimane prima o è meglio battere il (colle del) ferro quando è caldo? Si saprà il 30/7. A fronte di un’altra affluenza record dovremmo davvero chiederci se tra i titoli platonici che la città assume di tanto in tanto (“Città dello spazio”, “Città della cultura”, “città del betaesaclorocicloesano”, “Città dell’omicidio di Willy Monteiro”) non vada ascritto, e per sempre, “Città della denz anni Novanta”.
Sabino Capogreco

How to progamatically access kubernetes cluster with aws-iam-authenticator
(this appeared also on @Medium)
DISCLAIMER: all keys, secrets, and access info are not working. They are just for explanation purposes.
I need to access a Kubernetes (k8s) cluster and verify the version, status, or whatever of Pods inside the cluster. This can be done with kubectl binary given by k8s but also programmatically using client and SDK developed by kubernetes team.
kubectl client, which can be used from terminal/bash, has some simple configuration (it depends on your implementation). Mine was:
AWS ACCESS_KEY, SECRET and REGION should be exported as environment variables, so before all, there should be something like this (this is valid for Apple, Windows, and Linux may have different syntax)
export AWS_ACCESS_KEY_ID=IOP342752ADE3456156 export AWS_SECRET_ACCESS_KEY=KN!/kFssdfFWewcASF12dasWE365574FFo export AWS_DEFAULT_REGION=eu-west-1
Then there is a file used for configuration, named .kubenv, which paths should be exported as well
export KUBECONFIG=/home/mysuer/.kubenv
The file content is something like this (is in YML format)
apiVersion: v1 clusters: - cluster: certificate-authority-data: 4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw== server: https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7.eu-west-1.eks.amazonaws.com name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 contexts: - context: cluster: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 user: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 current-context: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 kind: Config preferences: {} users: - name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 user: exec: apiVersion: client.authentication.k8s.io/v1beta1 args: - token - -i - a-k8s-cluster-01 command: /var/bin/aws-iam-authenticator env: - name: "AWS_PROFILE" value: "this-is-a-k8s-clusters" interactiveMode: IfAvailable provideClusterInfo: false
After the two exports, you can easily use this command to get all the namespaces from Kubernetes cluster:
kubectl get namespaces
And, for each namespace, get information about PODS
kubectl get deployments -o wide -n A_NAMESPACE
…where A_NAMESPACE should be each namespace returned from the previous command.
How to do authentication and retrieve POD information from k8s (kubernetes) cluster in Java
To do the same using Java client, first of all we should authenticate in the k8s (Kubernetes) cluster and we should follow some steps.
Export AWS secret, access keys and regions
This part can not be skipped, so even in Java we should export this value right before running every code
export AWS_ACCESS_KEY_ID=IOP342752ADE3456156 export AWS_SECRET_ACCESS_KEY=KN!/kFssdfFWewcASF12dasWE365574FFo export AWS_DEFAULT_REGION=eu-west-1
I want to emulate this Code Example for kubernetes Java client but with all the authentication prerequisites. I need some modification that results in this code snippet
Region myRegion = Regions.EU_WEST_1; String clusterName = "a-k8s-cluster-01"; String clusterHost = "https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7."; String certificate = "4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw=="; AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); AWSSecurityTokenServiceClient tokenService = (AWSSecurityTokenServiceClient) AWSSecurityTokenServiceClientBuilder .standard() .withCredentials(credentialsProvider) .withRegion(myRegion) .build(); String initialToken = generateToken(clusterName, new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60)), "sts", myRegion.getName(), tokenService, credentialsProvider, "https", "sts." + myRegion.getName() + ".amazonaws.com"); byte[] bytes = Base64.getDecoder().decode(certificate.getBytes()); String endPoint = clusterHost + myRegion.getName() + ".eks.amazonaws.com"; client = (new ClientBuilder()) .setBasePath(endPoint) .setAuthentication(new AccessTokenAuthentication(initialToken)) .setVerifyingSsl(true) .setCertificateAuthority(bytes) .build(); Configuration.setDefaultApiClient(client); CoreV1Api api = new CoreV1Api(); V1NamespaceList namespaces = api.listNamespace(null, null, null, null, null, -1, null, null, 30, false); ... .. .
After this, having namespaces and api instantiated, everything is straightforward. Before analyzing how we arrive at this solution, let me add also the snippet for the method generateToken that is a copy/paste from this thread it works so no need to investigate further
private String generateToken(String clusterName, Date expirationDate, String serviceName, String region, AWSSecurityTokenServiceClient awsSecurityTokenServiceClient, AWSCredentialsProvider credentialsProvider, String scheme, String host) throws URISyntaxException { try { DefaultRequest<GetCallerIdentityRequest> callerIdentityRequestDefaultRequest = new DefaultRequest<>(new GetCallerIdentityRequest(), serviceName); URI uri = new URI(scheme, host, null, null); callerIdentityRequestDefaultRequest.setResourcePath("/"); callerIdentityRequestDefaultRequest.setEndpoint(uri); callerIdentityRequestDefaultRequest.setHttpMethod(HttpMethodName.GET); callerIdentityRequestDefaultRequest.addParameter("Action", "GetCallerIdentity"); callerIdentityRequestDefaultRequest.addParameter("Version", "2011-06-15"); callerIdentityRequestDefaultRequest.addHeader("x-k8s-aws-id", clusterName); Signer signer = SignerFactory.createSigner(SignerFactory.VERSION_FOUR_SIGNER, new SignerParams(serviceName, region)); SignerProvider signerProvider = new DefaultSignerProvider(awsSecurityTokenServiceClient, signer); PresignerParams presignerParams = new PresignerParams(uri, credentialsProvider, signerProvider, SdkClock.STANDARD); PresignerFacade presignerFacade = new PresignerFacade(presignerParams); URL url = presignerFacade.presign(callerIdentityRequestDefaultRequest, expirationDate); String encodedUrl = Base64.getUrlEncoder().withoutPadding().encodeToString(url.toString().getBytes()); log.info("Token [{}]", encodedUrl); return "k8s-aws-v1." + encodedUrl; } catch (URISyntaxException e) { log.error("could not generate token", e); throw e; } }
The main part of the code is “how we move from .kubenv config file to a Java code solution”. The following variables
Region myRegion = Regions.EU_WEST_1; String clusterName = "a-k8s-cluster-01"; String clusterHost = "https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7."; String certificate = "4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw==";
Are easy to explain:
myRegion: is a region that you may find in the .kubenv config file, in every server or host there should be something like “eu-west-1”
clusterName: is the cluster name, you may find it in your .kubenv config file, as the final part of the node hierarchy clusters-cluster-name or in the field users -> user -> exec -> args. It is used as an argument when we call the binary aws-iam-authenticator
clusterHost: in the kube config file .kubenv is the field cluster -> cluster -> server
certificate: in the kube config file .kubenv is the field cluster -> certificate-authority-data. This represents a base64 encoded certificate, if you decode it with a simple Base6e decoder, the string results is
—–BEGIN CERTIFICATE—– MIIC/jCCl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp 38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== —–END CERTIFICATE—–
So everything should work as expected and you should have access to all the API in Java.

Come accedere a un cluster kubernetes con autenticazione aws-iam-authenticator
DISCLAIMER: tutte le chiavi, i segreti e le informazioni d’accesso sono per puro scopo di spiegazione e non funzionano.
Avevo bisogno di accede ad un cluster Kubernetes (k8s) cluster e verificare le versioni, lo stato o altre varie cose dei Pod che sono dentro al cluster. Questo può essere fatto con il client kubectl che è un binario fornito dai creatori di k8s proprio. ma si può anche fare programmaticamente in Java usando un client sviluppato dal team di kubernetes.
kubectl può essere usato da terminale e console e ha bisogno di qualche semplice configurazione. La mia era:
AWS ACCESS_KEY, SECRET e REGION devono essere esportati come variabili d’ambiente quindi, prima di tutto, bisogna fare una roba del genere (questo è valido per Apple. Per Windows e Linux la sintessi è leggeremente diversa)
export AWS_ACCESS_KEY_ID=IOP342752ADE3456156 export AWS_SECRET_ACCESS_KEY=KN!/kFssdfFWewcASF12dasWE365574FFo export AWS_DEFAULT_REGION=eu-west-1
Dopodichè c’è un file di configurazione, e del quale esportato il path
export KUBECONFIG=/home/mysuer/.kubenv
Nel file .kubenv c’è della roba del genere (il formato del file è YML)
apiVersion: v1 clusters: - cluster: certificate-authority-data: 4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw== server: https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7.eu-west-1.eks.amazonaws.com name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 contexts: - context: cluster: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 user: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 current-context: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 kind: Config preferences: {} users: - name: arn:aws:eks:eu-west-1:111111111111:cluster/a-k8s-cluster-01 user: exec: apiVersion: client.authentication.k8s.io/v1beta1 args: - token - -i - a-k8s-cluster-01 command: /var/bin/aws-iam-authenticator env: - name: "AWS_PROFILE" value: "this-is-a-k8s-clusters" interactiveMode: IfAvailable provideClusterInfo: false
Dopo l’export si può usare il comando per prendere tutti i namespace dal cluster Kubernetes:
kubectl get namespaces
E per ogni namespace, si prendono le informazioni dei PODS
kubectl get deployments -o wide -n A_NAMESPACE
sostituendo A_NAMESPACE con i vari namespace del precedente comando.
Come autenticarsi e prendere le informazioni sui POD da un cluster k8s (kubernetes) in Java
Per fare la stessa cosa in Java, si usa un Java client e per prima cosa bisogna autenticarsi su k8s (Kubernetes) sequendo i seguenti passi:
Esportare AWS secret, access key e region
Questa parte non può essere skippata, quindi anche in Java dobbiamo esportare queste variabili prima di far girare il codice
export AWS_ACCESS_KEY_ID=IOP342752ADE3456156 export AWS_SECRET_ACCESS_KEY=KN!/kFssdfFWewcASF12dasWE365574FFo export AWS_DEFAULT_REGION=eu-west-1
Dopodichè, seguendo questo esempio Code Example for kubernetes Java client , la prima cosa da fare è l’autenticazione. A tal riguardo ho bisogno di un poco di modifiche
Region myRegion = Regions.EU_WEST_1; String clusterName = "a-k8s-cluster-01"; String clusterHost = "https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7."; String certificate = "4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw=="; AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain(); AWSSecurityTokenServiceClient tokenService = (AWSSecurityTokenServiceClient) AWSSecurityTokenServiceClientBuilder .standard() .withCredentials(credentialsProvider) .withRegion(myRegion) .build(); String initialToken = generateToken(clusterName, new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60)), "sts", myRegion.getName(), tokenService, credentialsProvider, "https", "sts." + myRegion.getName() + ".amazonaws.com"); byte[] bytes = Base64.getDecoder().decode(certificate.getBytes()); String endPoint = clusterHost + myRegion.getName() + ".eks.amazonaws.com"; client = (new ClientBuilder()) .setBasePath(endPoint) .setAuthentication(new AccessTokenAuthentication(initialToken)) .setVerifyingSsl(true) .setCertificateAuthority(bytes) .build(); Configuration.setDefaultApiClient(client); CoreV1Api api = new CoreV1Api(); V1NamespaceList namespaces = api.listNamespace(null, null, null, null, null, -1, null, null, 30, false); ... .. .
Dopo di questo, avendo i namespace e le api instanziate, il tutto è piuttosto semplice. Prima di analizzare la soluzione, lasciatemi aggiungere lo snippet del codice di generateToken che è un copy/paste da questo thread e siccome funziona, io non investigheri più di tanto
private String generateToken(String clusterName, Date expirationDate, String serviceName, String region, AWSSecurityTokenServiceClient awsSecurityTokenServiceClient, AWSCredentialsProvider credentialsProvider, String scheme, String host) throws URISyntaxException { try { DefaultRequest<GetCallerIdentityRequest> callerIdentityRequestDefaultRequest = new DefaultRequest<>(new GetCallerIdentityRequest(), serviceName); URI uri = new URI(scheme, host, null, null); callerIdentityRequestDefaultRequest.setResourcePath("/"); callerIdentityRequestDefaultRequest.setEndpoint(uri); callerIdentityRequestDefaultRequest.setHttpMethod(HttpMethodName.GET); callerIdentityRequestDefaultRequest.addParameter("Action", "GetCallerIdentity"); callerIdentityRequestDefaultRequest.addParameter("Version", "2011-06-15"); callerIdentityRequestDefaultRequest.addHeader("x-k8s-aws-id", clusterName); Signer signer = SignerFactory.createSigner(SignerFactory.VERSION_FOUR_SIGNER, new SignerParams(serviceName, region)); SignerProvider signerProvider = new DefaultSignerProvider(awsSecurityTokenServiceClient, signer); PresignerParams presignerParams = new PresignerParams(uri, credentialsProvider, signerProvider, SdkClock.STANDARD); PresignerFacade presignerFacade = new PresignerFacade(presignerParams); URL url = presignerFacade.presign(callerIdentityRequestDefaultRequest, expirationDate); String encodedUrl = Base64.getUrlEncoder().withoutPadding().encodeToString(url.toString().getBytes()); log.info("Token [{}]", encodedUrl); return "k8s-aws-v1." + encodedUrl; } catch (URISyntaxException e) { log.error("could not generate token", e); throw e; } }
La parte principale del codice è “come ci siamo spostati da un file di configurazione .kubenv a del codice Java”. Le seguenti variabili
Region myRegion = Regions.EU_WEST_1; String clusterName = "a-k8s-cluster-01"; String clusterHost = "https://ABCDEFGHILMNOPQRSTUVZ1234567890.gr7."; String certificate = "4oCU4oCTQkVHSU4gQ0VSVElGSUNBVEXigJTigJMKTUlJQy9qQ0NsMmdBd0lCQWdJTEJBQUFBQUFCRlV0YXc1UXdEUVlKS29aSWh2Y05BUUVGQlFBd1Z6RUxNQWtHCllXeFRhV2R1SUc1MkxYTmhNUkF3RGdZRFZRUUxFd2RTYjI5MElFTkJNUnN3R1FZRFZRUURFeEpIYkc5aVlXeFQKYVdkdUlGSnZiM1FnUTBFd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUURhRHVhWgpqYzZqNDArS2Z2dnhpNE1sYStwSUgvRXFzTG1WRVFTOThHUFI0bWRtenh6ZHp4dElLKzZOaVk2YXJ5bUFaYXZwCjM4TmZsTlVWeVJSQm5NUmRkV1FWRGY5Vk1PeUdqLzhON3l5NVkwYjJxdnpmdkduOUxoSklaSnJnbGZDbTd5bVAKSE1VZnBJQnZGU0RKM2d5SUNoM1dabFhpL0VqSktTWnA0QT09CuKAlOKAk0VORCBDRVJUSUZJQ0FUReKAlOKAkw==";
Sono semplici da spiegare:
myRegion: è la regione AWS e si trova nel file di configurazione .kuebenv, in ogni server o host dovrebbe esserci qualcosa come “eu-west-1”
clusterName: è il nome del cluster, potresti trovarlo nel file di configurazione .kuebenv come parte finale dei nodi clusters -> cluster -> name oppure nel campo users -> user -> exec -> args sempre del file .kuebenv e viene utilizzato come argomento quando chiamiamo il file binario aws-iam-authenticator
clusterHost: nel file di configurazione di .kuebenv è il campo cluster -> cluster -> server
certificate: nel file di configurazione di .kuebenv è il campo cluster -> certificate-authority-data. Questo rappresenta un certificato codificato Base64, se lo decodifichi con un semplice decoder Base6e, quello che esce fuori è il seguente testo
—–BEGIN CERTIFICATE—– MIIC/jCCl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp 38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== —–END CERTIFICATE—–
Quindi tutto dovrebbere funzionare e dovresti avere accesso a tutte le API in Java.
Riferimenti:

Katzenjammer del 15 Luglio 2024
Podcast: Play in new window
Subscribe: RSS
Scaletta di Katzenjammer del 15 July 2024
Billie Eilish – BIRDS OF A FEATHER
Frank Turner, Fast Animals and Slow Kids – Do One
ANNA, Guè – BIKINI
Valerio Lundini, Vazzanikki – Parabola Ascendente
Eddie Vedder – Save It For Later
Pearl Jam – Alive
Royal Division – Piogge Acide
Taylor Swift – Cruel Summer
Joan Jett & the Blackhearts – Bad Reputation
L7 – Pretend We’re Dead
Hole – Malibu
Linkin Park – In the End
Subsonica – Tutti I Miei Sbagli
Foo Fighters – My Hero
Thirty Seconds To Mars – The Kill
Sick Tamburo – Un giorno nuovo

Katzenjammer del 8 Luglio 2024
Podcast: Play in new window
Subscribe: RSS
Scaletta della puntata di Katzenjammer del 8 luglio 2024
Sabrina Carpenter – Please Please Please title
Shaboozey – A Bar Song title
Diodato – Molto amore title
Bodyrockers – I Like The Way title
FoFoForever, Francesco De Leo – Ombrastella title
Kasabian – Italian Horror title
Beach Bunny – Prom Queen title
GIIN – Cuore di plastica title
Bring Me The Horizon – Top 10 staTues tHat CriEd bloOd title
AC/DC – T.N.T. title
Pale Waves – Perfume title
Pierce The Veil – Karma Police title
blink-182 – Bored To Death title
Bad Religion – Stranger Than Fiction title
Ministri – Diritto Al Tetto title
Paolo Benvegnù – Pescatori di Perle
Frankie hi-nrg mc, Riccardo Sinigallia – Quelli che benpensano title

Katzenjammer del 1 luglio 2024
Podcast: Play in new window
Subscribe: RSS
Scaletta di Katzenjammer del 1 luglio 2024
Hozier – Too Sweet
Pitbull, Ne-Yo, AFROJACK, DJ Buddha – 2 The Moon
Cigarettes After Sex – Baby Blue Movie
The Hives – Tick Tick Boom
IDLES – Roy
Fontaines D.C. – Favourite
Travis – Bus
Foo Fighters – The Pretender
Pixies – You’re So Impatient
Piero Pelù – CANTO
Litfiba – Istanbul
Wilco – Impossible Germany
Lenny Kravitz – Paralyzed
Kasabian – Darkest Lullaby
Linkin Park – Bleed It Out
Natalie Imbruglia – Pigeons and Crumbs