Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JCConf 2021 Access Kubernetes API in Java
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Shihyu Ho
November 19, 2021
Technology
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JCConf 2021 Access Kubernetes API in Java
Access Kubernetes API in Java
Shihyu Ho
November 19, 2021
More Decks by Shihyu Ho
See All by Shihyu Ho
JCConf 2024 Jib
shihyuho
0
110
JCConf 2022 - Using ArchUnit to test your architecture
shihyuho
0
170
hybrid-cloud-seminar.pdf
shihyuho
0
130
JCConf 2020 Observing in Microservices
shihyuho
0
880
iThome Kubernetes Summit 2018
shihyuho
0
77
JCConf 2016 zookeeper
shihyuho
0
88
Other Decks in Technology
See All in Technology
FDE という解 ― 暗黙知と明示知をつなぐ、伴走型エンジニアリング ―
otanet
0
130
LLMにもCAP定理があるという話
harukasakihara
0
290
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
9
670
Microsoft Build Keynoteふりかえり
tomokusaba
0
120
失敗を資産に変えるClaude Code
shinyasaita
0
320
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
780
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
530
10倍の生産性を実現するAI駆動並列エージェントのすべて
kumaiu
5
1.3k
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
130
LLMと共に進化するプロセスを目指して
ymatsuwitter
12
4k
小さく始める AI 活用推進 ― 日経電子版 Web チームの事例/nikkei-tech-talk47
nikkei_engineer_recruiting
0
220
失敗を経て、Harness Engineering で 大切にしたいことを考える / Learning from Failure: What Matters in Harness Engineering
bitkey
PRO
1
300
Featured
See All Featured
The Curious Case for Waylosing
cassininazir
1
380
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
220
Balancing Empowerment & Direction
lara
6
1.2k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
940
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
730
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
420
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.3k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
970
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
4 Signs Your Business is Dying
shpigford
187
22k
Transcript
JCConf Taiwan 2021 Access Kubernetes API in Java Matt Ho
Access Kubernetes API in Java
Hi, I'm Matt https://github.com/shihyuho
[email protected]
@SoftLeader Access Kubernetes API in
Java
Requirements Some experience with Java and Spring. Basic understanding of
Kubernetes. YAML language. Access Kubernetes API in Java
你爲什麼會需要去跟 Kubernetes 互動? Access Kubernetes API in Java
Kubernetes Architecture Access Kubernetes API in Java
Kubernetes Architecture Access Kubernetes API in Java
環境準備 Local Kubernetes cluster 推薦: docker + minikube # Start
the cluster $ minikube start # Configure environment to use minikube’s Docker daemon $ eval $(minikube docker-env) # Halt the cluster $ minikube stop Access Kubernetes API in Java
環境準備 A simple web app w/ Spring Boot $ curl
https://start.spring.io/starter.zip \ -d dependencies=web,lombok,devtools \ -d bootVersion=2.5.7 \ -o demo.zip Access Kubernetes API in Java
環境準備 Add the following dependency to your pom.xml file: <dependency>
<groupId>io.fabric8</groupId> <artifactId>kubernetes-client</artifactId> <version>5.10.1</version> </dependency> <!-- Optional --> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.5.12</version> </dependency> Access Kubernetes API in Java
Kubernetes Java Client Officially-supported - kubernetes-client/java Community-maintained - fabric8io/kubernetes-client Access
Kubernetes API in Java
起手式 try (var client = new DefaultKubernetesClient()) { client.{apiGroup}.{apiVersion}.{resource}.{verb}... }
Access Kubernetes API in Java
kubectl get pod -n default kubectl get service -A kubectl
get deploy -l my=label kubectl get cronjob myjob Access Kubernetes API in Java
A Hello Pod apiVersion: v1 kind: Pod metadata: name: hello
spec: containers: - name: hello image: busybox imagePullPolicy: IfNotPresent command: ["sh", "-c", "echo Hello JCConf Taiwan; sleep 2"] restartPolicy: Never Access Kubernetes API in Java
Builder Pattern new {Resource}Builder() .withNew{FieldObject} .with{Field}(...) .with{Field}(...) .end{FieldObject} .build(); Access
Kubernetes API in Java
Packing Image mvn compile com.google.cloud.tools:jib-maven-plugin:3.1.4:dockerBuild -Djib.to.image=demo:1.0.0 # mvn spring-boot:build-image -Dspring-boot.build-image.imageName=demo:1.0.0
Access Kubernetes API in Java
Deploy apiVersion: apps/v1 kind: Deployment metadata: name: demo spec: selector:
matchLabels: app: demo template: metadata: labels: app: demo spec: containers: - name: demo image: demo:1.0.0 Access Kubernetes API in Java
Kubernetes RBAC Access Kubernetes API in Java
Kubernetes RBAC Access Kubernetes API in Java
Kubernetes RBAC Access Kubernetes API in Java
apiVersion: v1 kind: ServiceAccount metadata: name: demo namespace: default ---
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: demo rules: - apiGroups: [ "" ] resources: [ "pods" ] verbs: [ "get", "list", "watch", "create", "update", "patch", "delete" ] - apiGroups: [ "" ] resources: [ "events" ] verbs: [ "list" ] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: demo roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: demo subjects: - kind: ServiceAccount name: demo namespace: default Access Kubernetes API in Java
Recap Basic understanding of Kubernetes API. How to access Kubernetes
API in Java. How to configure access control to the app. Demo code. Access Kubernetes API in Java
Thank you Access Kubernetes API in Java