guestbook-ui.jsonnet 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. local env = std.extVar("__ksonnet/environments");
  2. local params = std.extVar("__ksonnet/params").components["guestbook-ui"];
  3. [
  4. {
  5. "apiVersion": "v1",
  6. "kind": "Service",
  7. "metadata": {
  8. "name": params.name
  9. },
  10. "spec": {
  11. "ports": [
  12. {
  13. "port": params.servicePort,
  14. "targetPort": params.containerPort
  15. }
  16. ],
  17. "selector": {
  18. "app": params.name
  19. },
  20. "type": params.type
  21. }
  22. },
  23. {
  24. "apiVersion": "apps/v1",
  25. "kind": "Deployment",
  26. "metadata": {
  27. "name": params.name
  28. },
  29. "spec": {
  30. "replicas": params.replicas,
  31. "revisionHistoryLimit": 3,
  32. "selector": {
  33. "matchLabels": {
  34. "app": params.name
  35. },
  36. },
  37. "template": {
  38. "metadata": {
  39. "labels": {
  40. "app": params.name
  41. }
  42. },
  43. "spec": {
  44. "containers": [
  45. {
  46. "image": params.image,
  47. "name": params.name,
  48. "ports": [
  49. {
  50. "containerPort": params.containerPort
  51. }
  52. ]
  53. }
  54. ]
  55. }
  56. }
  57. }
  58. }
  59. ]