Skip to content

Commit

Permalink
Should now push up to dockerhub.
Browse files Browse the repository at this point in the history
  • Loading branch information
BobJWalker committed Jan 5, 2024
1 parent ed5de76 commit 204e70b
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ jobs:
uses: gittools/actions/gitversion/[email protected]
with:
additionalArguments: /overrideconfig mode=Mainline
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_SAMPLES_USERNAME }}
password: ${{ secrets.DOCKERHUB_SAMPLES_PASSWORD }}
- name: build and push website container
working-directory: src
run: |
docker build -f "./RandomQuotes.Web/Dockerfile" --tag randomquotes-k8s:${{ steps.determine_version.outputs.semVer }} --tag randomquotes-k8s:latest .
docker build -f "./RandomQuotes.Web/Dockerfile" --tag octopussamples/randomquotes-k8s:${{ steps.determine_version.outputs.semVer }} --tag octopussamples/randomquotes-k8s:latest .
docker push octopussamples/randomquotes-k8s:${{ steps.ReleaseNum.outputs.APP_VERSION }}
docker push octopussamples/randomquotes-k8s:latest
38 changes: 38 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
This is a sample application deploy to Kubernetes. It's a good first application as it has no other components, but has an environment variable you can use to practice secrets on.

# Prep Work

- Install minikube, rancher desktop, or docker desktop locally.
- Open up a command prompt or terminal. Change the current directory to `k8s/provision` folder in this repo.
- Run the following commands:
- Create all the namespaces: `kubectl apply -f namespaces.yaml`
- Create the service account for deployments: `kubectl apply -f service-account-and-token.yaml`
- To get the token value run: `kubectl describe secret octopus-svc-account-token`. Copy the token to a file for future usage.
- Install the NGINX Ingress Controller: `kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.9.5/deploy/static/provider/cloud/deploy.yaml`
- Go to your hosts file (if on Windows and add the following entries)

```
127.0.0.1 randomquotes.local
127.0.0.1 randomquotesdev.local
127.0.0.1 randomquotestest.local
127.0.0.1 randomquotesstaging.local
127.0.0.1 randomquotesprod.local
```

# Basic Deployment

In the first activity we will do a standard manifest file deployment to the default namespace in kubernetes using `kubectl apply`.

Instructions Lorem Ipsum

# Leveraging Kustomize

In the second activity we will deploy to each of the environment namespaces using kustomize and overlays.

Instructions Lorem Ipsum

# Using Octopus Deploy

In the final activity we will configure Octopus Deploy to deploy our application to k8s using the manifest files.

Instructions Lorem Ipsum
5 changes: 5 additions & 0 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- randomquotes-deployment.yaml
64 changes: 64 additions & 0 deletions k8s/base/randomquotes-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: randomquotes-deployment
spec:
replicas: 1
selector:
matchLabels:
component: randomquotes-web
template:
metadata:
labels:
component: randomquotes-web
spec:
containers:
- name: randomquotes-web
image: octopussamples/randomquotes:0.0.1
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
imagePullPolicy: "Always"
ports:
- containerPort: 5000
name: http-port
env:
- name: RANDOM_SECRET_PHRASE
valueFrom:
secretKeyRef:
name: random-quotes-secrets
key: homepageDisplay
---
apiVersion: v1
kind: Service
metadata:
name: randomquotes-app-cluster-ip-service
spec:
type: ClusterIP
selector:
component: randomquotes-web
ports:
- port: 6801
targetPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: randomquotes-ingress-nginx
spec:
ingressClassName: nginx
rules:
- host: randomquotes.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: randomquotes-app-cluster-ip-service
port:
number: 6801
7 changes: 7 additions & 0 deletions k8s/base/randomquotes-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: random-quotes-secrets
type: Opaque
stringData:
homepageDisplay: "blah"
19 changes: 19 additions & 0 deletions k8s/provision/namespaces.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: Namespace
metadata:
name: dev
---
apiVersion: v1
kind: Namespace
metadata:
name: testing
---
apiVersion: v1
kind: Namespace
metadata:
name: staging
---
apiVersion: v1
kind: Namespace
metadata:
name: production
69 changes: 69 additions & 0 deletions k8s/provision/service-account-and-token.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: octopus-svc-account
namespace: default
---
apiVersion: v1
kind: Secret
metadata:
name: octopus-svc-account-token
namespace: default
annotations:
kubernetes.io/service-account.name: octopus-svc-account
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: octopus-svc-account-role
namespace: default
rules:
- apiGroups:
- ""
- apps
- autoscaling
- batch
- extensions
- policy
- "rbac.authorization.k8s.io"
- "networking.k8s.io"
- secrets
resources:
- pods
- componentstatuses
- configmaps
- daemonsets
- deployments
- events
- endpoints
- horizontalpodautoscalers
- ingress
- ingresses
- jobs
- limitranges
- namespaces
- nodes
- pods
- persistentvolumes
- persistentvolumeclaims
- resourcequotas
- replicasets
- replicationcontrollers
- serviceaccounts
- services
- secrets
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: octopus-svc-account-role-binding
subjects:
- namespace: default
kind: ServiceAccount
name: octopus-svc-account
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: octopus-svc-account-role

0 comments on commit 204e70b

Please sign in to comment.