You can use the k8s module for this purpose. It helps manage all k8s objects. Have a look at this example:
- name: Create service object from an inline definition
k8s:
state: present
definition:
apiVersion: v1
kind: Service
metadata:
name: webpage
namespace: testing
labels:
app: galaxy
service: webpage
spec:
selector:
app: galaxy
service: webpage
ports:
- protocol: TCP
targetPort: 8000
name: port-8000-tcp
port: 8000