Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ jobs:
run: |
IMAGE_TAG=${{ github.sha }}
docker build -t $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG .
docker tag $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:latest
docker push $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:$IMAGE_TAG
docker push $ECR_REGISTRY/${{ secrets.ECR_REPOSITORY }}:latest

- name: Bump image tag in infra repo
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
INFRA_REPO_TOKEN: ${{ secrets.INFRA_REPO_TOKEN }}
run: |
git clone https://x-access-token:${INFRA_REPO_TOKEN}@github.com/DGU-CAP/infra.git infra-repo
cd infra-repo/k8s/manifests/overlays/eks/backend

# kustomize가 없으면 설치
if ! command -v kustomize &> /dev/null; then
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
sudo mv kustomize /usr/local/bin/
fi

kustomize edit set image \
428185450315.dkr.ecr.ap-northeast-2.amazonaws.com/dgu-cap-backend=428185450315.dkr.ecr.ap-northeast-2.amazonaws.com/dgu-cap-backend:${{ github.sha }}

git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add kustomization.yaml
git commit -m "chore: bump backend image to ${{ github.sha }}"
git push origin main
16 changes: 12 additions & 4 deletions src/main/java/com/dgu/cap/kubernetes/PodController.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ public class PodController {

@GetMapping("/pods")
public ResponseEntity<List<PodInfo>> getPods(
@RequestParam(defaultValue = "default") String namespace) {
@RequestParam(required = false) String namespace) {
if (namespace == null || namespace.isBlank()) {
return ResponseEntity.ok(kubernetesService.getAllPods());
}
return ResponseEntity.ok(kubernetesService.getPods(namespace));
}

@GetMapping("/pods/{podName}/events")
public ResponseEntity<List<PodEvent>> getPodEvents(
@PathVariable String podName,
@RequestParam(defaultValue = "default") String namespace) {
return ResponseEntity.ok(kubernetesService.getPodEvents(podName, namespace));
@RequestParam(required = false) String namespace) {
String ns = (namespace == null || namespace.isBlank()) ? "default" : namespace;
return ResponseEntity.ok(kubernetesService.getPodEvents(podName, ns));
}

@GetMapping("/topology")
public ResponseEntity<Map<String, Object>> getTopology(
@RequestParam(defaultValue = "default") String namespace) {
@RequestParam(required = false) String namespace) {
if (namespace == null || namespace.isBlank()) {
List<PodInfo> pods = kubernetesService.getAllPods();
return ResponseEntity.ok(Map.of("pods", pods, "namespace", "all"));
}
List<PodInfo> pods = kubernetesService.getPods(namespace);
return ResponseEntity.ok(Map.of("pods", pods, "namespace", namespace));
}
Expand Down
Loading