- Create a new namespace 'nexus' in your cluster.
oc new-project nexus
- Create a new PersistentVolumeClaim
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nexus-data
namespace: nexus
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
- Create a new deployment called
nexus
which exposes two ports8081
and8082
apiVersion: apps/v1
kind: Deployment
metadata:
name: nexus
namespace: nexus
spec:
replicas: 1
selector:
matchLabels:
app: nexus
template:
metadata:
labels:
app: nexus
spec:
containers:
- name: nexus
image: sonatype/nexus3
ports:
- containerPort: 8081
- containerPort: 8082
volumeMounts:
- mountPath: /nexus-data
name: nexus-data
volumes:
- name: nexus-data
persistentVolumeClaim:
claimName: nexus-data
- Create a service for the nexus deployment
apiVersion: v1
kind: Service
metadata:
name: nexus
namespace: nexus
spec:
ports:
- port: 8081
name: nexus-web
- port: 8082
name: nexus-repo
selector:
app: nexus
type: LoadBalancer
- expose the service targetting different ports.
oc expose svc/nexus --name=nexus-web --port=nexus-web --namespace=nexus
oc expose svc/nexus --name=nexus-repo --port=nexus-repo --namespace=nexus
- Go to the Administrator -> Networking -> routes section in openshift and open the nexus-web ui link.
- Click on the
Sign In
button from the top right corner.
username: admin
password: xxx // This can be found in the /nexus-data/admin-password file in the nexus pod.
- Change the admin password and click next to finish the intial setup.
- Now click on Settings -> repository -> Create repository and choose
docker (hosted)
repository.
- Provide the port number
8082
and enable the docker v1 api and click on save at the bottom of the file.
- Go to the realms on the left navigation bar and click on Docker bearer token and save the settings.
- Now you should be able to login to the docker repo
podman login -u admin http://nexus-repo-nexus.<cluster-host-name> --tls-verify=false
Password:xxx
Login Succeeded!
- Tag and push an image to the nexus docker repo
❯ podman pull hello:latest
❯ podman tag 5dd467fce50b nexus-repo-nexus.apps.cluster-s274l.sandbox2448.opentlc.com/sample/hello
❯ podman push nexus-repo-nexus.apps.cluster-s274l.sandbox2448.opentlc.com/sample/hello:latest --tls-verify=false
Now the image will be available on the nexus repo.
`